# HG changeset patch # User Marcin Kuzminski # Date 2010-09-19 01:29:49 # Node ID b12ea84fb9061ebed9f3ea4e95499559573af2e8 # Parent 5c376ac2d4c9ec01c298d1fc4351d3678fb68233 Some fixes to summary, and total rewrite of summary graphs implemented more interactive graph. Some small fixes for tasks (sorting,limit) diff --git a/pylons_app/lib/celerylib/__init__.py b/pylons_app/lib/celerylib/__init__.py --- a/pylons_app/lib/celerylib/__init__.py +++ b/pylons_app/lib/celerylib/__init__.py @@ -14,13 +14,16 @@ class ResultWrapper(object): def result(self): return self.task -def run_task(task,*args,**kwargs): +def run_task(task, *args, **kwargs): try: - t = task.delay(*args,**kwargs) - log.info('running task %s',t.task_id) + t = task.delay(*args, **kwargs) + log.info('running task %s', t.task_id) return t - except: - log.error(traceback.format_exc()) + except Exception, e: + if e.errno == 111: + log.debug('Unnable to connect. Sync execution') + else: + log.error(traceback.format_exc()) #pure sync version - return ResultWrapper(task(*args,**kwargs)) - \ No newline at end of file + return ResultWrapper(task(*args, **kwargs)) + diff --git a/pylons_app/lib/celerylib/tasks.py b/pylons_app/lib/celerylib/tasks.py --- a/pylons_app/lib/celerylib/tasks.py +++ b/pylons_app/lib/celerylib/tasks.py @@ -7,8 +7,9 @@ from pylons_app.lib.celerylib import run 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 @@ def get_commits_stats(repo): 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 @@ def get_commits_stats(repo): 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 @@ def get_commits_stats(repo): 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 @@ def get_commits_stats(repo): 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"] } diff --git a/pylons_app/templates/summary/summary.html b/pylons_app/templates/summary/summary.html --- a/pylons_app/templates/summary/summary.html +++ b/pylons_app/templates/summary/summary.html @@ -76,7 +76,9 @@ E.onDOMReady(function(e){
- ${h.age(c.repo_info.last_change)} - ${h.rfc822date(c.repo_info.last_change)} + ${h.age(c.repo_info.last_change)} - ${h.rfc822date(c.repo_info.last_change)} + ${_('by')} ${c.repo_info.get_changeset('tip').author} +
@@ -121,7 +123,7 @@ E.onDOMReady(function(e){
-
${_('Last month commit activity')}
+
${_('Commit activity')}
@@ -136,191 +138,341 @@ E.onDOMReady(function(e){
+ YAHOO.util.Event.on(choiceContainer.getElementsByTagName("input"), "click", plotchoiced, [data, initial_ranges]); + } + SummaryPlot(${c.ts_min},${c.ts_max},${c.commit_data|n},${c.overview_data|n}); +