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
}
评论列表
文章目录