models.py 文件源码

python
阅读 17 收藏 0 点赞 0 评论 0

项目:minstances 作者: 0xa 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号