def score_capabilities(self):
# TODO: Is that limit justified?
https = hcase(
self.https_available,
hlimit((hcoalesce(self.https_grade, 0)) / len(SSLLABS_GRADES), 0.5, 1),
0
)
ips = self.ipv4 * 0.5 + self.ipv6 * 0.5
# TODO: + same on the last few days?
avg_rtime_q = sql.select([sqlf.coalesce(sqlf.sum(Ping.response_time)/sqlf.count(), 0).label('c')]).where((Ping.instance_id == self.id) & (Ping.state == True)).alias('t')
avg_rtime = 1 - hlimit(hsubq(self, avg_rtime_q) / MAX_RESPONSE_TIME_MS, 0, 1)
if isinstance(self, Instance):
logger.debug("score:caps: tls=%.2f ips=%.2f rtime=%.2f",
https, ips, avg_rtime)
return https * 0.50 + ips * 0.20 + avg_rtime * 0.30
评论列表
文章目录