diff pylons_app/lib/celerylib/tasks.py @ 531:b12ea84fb906 celery

Some fixes to summary, and total rewrite of summary graphs implemented more interactive graph. Some small fixes for tasks (sorting,limit)
author Marcin Kuzminski <marcin@python-works.com>
date Sun, 19 Sep 2010 03:29:49 +0200
parents 5c376ac2d4c9
children 2256c78afe53
line wrap: on
line diff
--- a/pylons_app/lib/celerylib/tasks.py	Sat Sep 18 17:03:29 2010 +0200
+++ b/pylons_app/lib/celerylib/tasks.py	Sun Sep 19 03:29:49 2010 +0200
@@ -7,8 +7,9 @@
 from pylons_app.lib.helpers import person
 from pylons_app.lib.smtp_mailer import SmtpMailer
 from pylons_app.lib.utils import OrderedDict
+from operator import itemgetter
+from vcs.backends.hg import MercurialRepository
 from time import mktime
-from vcs.backends.hg import MercurialRepository
 import calendar
 import traceback
 import json
@@ -98,13 +99,14 @@
                         d, 0, 0, 0, 0, 0, 0,))
     
     ts_max_y = mktime((y, m, d, 0, 0, 0, 0, 0, 0,))
-
+    skip_date_limit = True
+    
     def author_key_cleaner(k):
         k = person(k)
         k = k.replace('"', "") #for js data compatibilty
         return k
             
-    for cs in repo[:1000]:#added limit 200 until fix #29 is made
+    for cs in repo[:200]:#added limit 200 until fix #29 is made
         k = '%s-%s-%s' % (cs.date.timetuple()[0], cs.date.timetuple()[1],
                           cs.date.timetuple()[2])
         timetupple = [int(x) for x in k.split('-')]
@@ -119,7 +121,7 @@
                 
             else:
                 #aggregate[author_key_cleaner(cs.author)].update(dates_range)
-                if k >= ts_min_y and k <= ts_max_y:
+                if k >= ts_min_y and k <= ts_max_y or skip_date_limit:
                     aggregate[author_key_cleaner(cs.author)][k] = {}
                     aggregate[author_key_cleaner(cs.author)][k]["commits"] = 1
                     aggregate[author_key_cleaner(cs.author)][k]["added"] = len(cs.added)
@@ -127,7 +129,7 @@
                     aggregate[author_key_cleaner(cs.author)][k]["removed"] = len(cs.removed) 
                                         
         else:
-            if k >= ts_min_y and k <= ts_max_y:
+            if k >= ts_min_y and k <= ts_max_y or skip_date_limit:
                 aggregate[author_key_cleaner(cs.author)] = OrderedDict()
                 #aggregate[author_key_cleaner(cs.author)].update(dates_range)
                 aggregate[author_key_cleaner(cs.author)][k] = {}
@@ -145,15 +147,19 @@
     overview_data = []
     for k, v in overview_aggregate.items():
         overview_data.append([k, v])
+    overview_data = sorted(overview_data, key=itemgetter(0))
     data = {}
     for author in aggregate:
-        data[author] = {"label":author,
-                      "data":[{"time":x,
+        commit_data = sorted([{"time":x,
                                "commits":aggregate[author][x]['commits'],
                                "added":aggregate[author][x]['added'],
                                "changed":aggregate[author][x]['changed'],
                                "removed":aggregate[author][x]['removed'],
                               } for x in aggregate[author]],
+                              key=itemgetter('time'))
+        
+        data[author] = {"label":author,
+                      "data":commit_data,
                       "schema":["commits"]
                       }