Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(960)

Unified Diff: commit_queue.py

Issue 12045029: Add CQ Top Score dashboard. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/chromium-status
Patch Set: Add "Top scores" link to all CQ pags Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « app.yaml ('k') | main.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: commit_queue.py
diff --git a/commit_queue.py b/commit_queue.py
index ef33d0dcb994f169ddef8a300aa9bf3f93db5762..b7b0b1319edfb956244a8ee2205fdb816c3b6645 100644
--- a/commit_queue.py
+++ b/commit_queue.py
@@ -315,12 +315,24 @@ class CQBasePage(BasePage):
class OwnerStats(object):
"""CQ usage statistics for a single user."""
def __init__(self, now, owner, last_day, last_week, last_month, forever):
+ # Since epoch in float.
self.now = now
+ # User instance.
self.owner = owner
+ assert all(isinstance(i, PendingCommit) for i in last_day)
self.last_day = last_day
+ assert all(isinstance(i, PendingCommit) for i in last_week)
self.last_week = last_week
+ assert isinstance(last_month, int)
self.last_month = last_month
+ assert isinstance(forever, int)
self.forever = forever
+ # Gamify ALL the things!
+ self.points = (
+ len(self.last_day) * 10 +
+ len(self.last_week) * 5 +
+ self.last_month + 2 +
+ self.forever)
class OwnerQuery(object):
@@ -402,6 +414,30 @@ class Summary(CQBasePage):
self.DisplayTemplate('cq_owners.html', template_values, use_cache=True)
+class TopScore(CQBasePage):
+ def _get_as_html(self, _):
+ owners = [
+ {
+ 'name': stats.owner.email.split('@', 1)[0].upper(),
+ 'points': stats.points,
+ }
+ for stats in monthly_top_contributors()
+ ]
+ owners.sort(key=lambda x: -x['points'])
+ for i in xrange(len(owners)):
+ if i == 0:
+ owners[i]['rank'] = '1st'
+ elif i == 1:
+ owners[i]['rank'] = '2nd'
+ elif i == 2:
+ owners[i]['rank'] = '3rd'
+ else:
+ owners[i]['rank'] = '%dth' % (i + 1)
+ template_values = self.InitializeTemplate(self.APP_NAME + ' Commit queue')
+ template_values['data'] = owners
+ self.DisplayTemplate('cq_top_score.html', template_values, use_cache=True)
+
+
class User(CQBasePage):
def _get_as_html(self, query):
pending_commits_events = {}
« no previous file with comments | « app.yaml ('k') | main.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698