util.py 文件源码

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

项目:t2-crash-reporter 作者: tessel 项目源码 文件源码
def trending(cls, start=None, limit=20):
        q = CrashReport.all()
        # only search for crashes that are not resolved
        q.filter('state IN ', ['unresolved', 'pending', 'submitted'])

        if start:
            q.filter('__key__ >', Key(start))
        q.order('__key__')
        q.order('name')
        q.order('-count')

        uniques = set()
        trending = list()
        has_more = False
        for crash_report in q.run():
            if len(uniques) > limit:
                has_more = True
                break
            else:
                if crash_report.name not in uniques:
                    uniques.add(crash_report.name)
                    crash_report = CrashReport.get_crash(crash_report.fingerprint)
                    trending.append(CrashReport.to_json(crash_report))

        trending = sorted(trending, key=lambda report: report['count'], reverse=True)
        return {
            'trending': trending,
            'has_more': has_more
        }
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号