Mercurial > public > src > rhodecode
comparison 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 |
comparison
equal
deleted
inserted
replaced
530:5c376ac2d4c9 | 531:b12ea84fb906 |
---|---|
5 from pylons.i18n.translation import _ | 5 from pylons.i18n.translation import _ |
6 from pylons_app.lib.celerylib import run_task | 6 from pylons_app.lib.celerylib import run_task |
7 from pylons_app.lib.helpers import person | 7 from pylons_app.lib.helpers import person |
8 from pylons_app.lib.smtp_mailer import SmtpMailer | 8 from pylons_app.lib.smtp_mailer import SmtpMailer |
9 from pylons_app.lib.utils import OrderedDict | 9 from pylons_app.lib.utils import OrderedDict |
10 from operator import itemgetter | |
11 from vcs.backends.hg import MercurialRepository | |
10 from time import mktime | 12 from time import mktime |
11 from vcs.backends.hg import MercurialRepository | |
12 import calendar | 13 import calendar |
13 import traceback | 14 import traceback |
14 import json | 15 import json |
15 | 16 |
16 __all__ = ['whoosh_index', 'get_commits_stats', | 17 __all__ = ['whoosh_index', 'get_commits_stats', |
96 d, 0, 0, 0, 0, 0, 0,)) | 97 d, 0, 0, 0, 0, 0, 0,)) |
97 ts_min_m = mktime((y, (td - timedelta(days=calendar.mdays[m])).month, | 98 ts_min_m = mktime((y, (td - timedelta(days=calendar.mdays[m])).month, |
98 d, 0, 0, 0, 0, 0, 0,)) | 99 d, 0, 0, 0, 0, 0, 0,)) |
99 | 100 |
100 ts_max_y = mktime((y, m, d, 0, 0, 0, 0, 0, 0,)) | 101 ts_max_y = mktime((y, m, d, 0, 0, 0, 0, 0, 0,)) |
101 | 102 skip_date_limit = True |
103 | |
102 def author_key_cleaner(k): | 104 def author_key_cleaner(k): |
103 k = person(k) | 105 k = person(k) |
104 k = k.replace('"', "") #for js data compatibilty | 106 k = k.replace('"', "") #for js data compatibilty |
105 return k | 107 return k |
106 | 108 |
107 for cs in repo[:1000]:#added limit 200 until fix #29 is made | 109 for cs in repo[:200]:#added limit 200 until fix #29 is made |
108 k = '%s-%s-%s' % (cs.date.timetuple()[0], cs.date.timetuple()[1], | 110 k = '%s-%s-%s' % (cs.date.timetuple()[0], cs.date.timetuple()[1], |
109 cs.date.timetuple()[2]) | 111 cs.date.timetuple()[2]) |
110 timetupple = [int(x) for x in k.split('-')] | 112 timetupple = [int(x) for x in k.split('-')] |
111 timetupple.extend([0 for _ in xrange(6)]) | 113 timetupple.extend([0 for _ in xrange(6)]) |
112 k = mktime(timetupple) | 114 k = mktime(timetupple) |
117 aggregate[author_key_cleaner(cs.author)][k]["changed"] += len(cs.changed) | 119 aggregate[author_key_cleaner(cs.author)][k]["changed"] += len(cs.changed) |
118 aggregate[author_key_cleaner(cs.author)][k]["removed"] += len(cs.removed) | 120 aggregate[author_key_cleaner(cs.author)][k]["removed"] += len(cs.removed) |
119 | 121 |
120 else: | 122 else: |
121 #aggregate[author_key_cleaner(cs.author)].update(dates_range) | 123 #aggregate[author_key_cleaner(cs.author)].update(dates_range) |
122 if k >= ts_min_y and k <= ts_max_y: | 124 if k >= ts_min_y and k <= ts_max_y or skip_date_limit: |
123 aggregate[author_key_cleaner(cs.author)][k] = {} | 125 aggregate[author_key_cleaner(cs.author)][k] = {} |
124 aggregate[author_key_cleaner(cs.author)][k]["commits"] = 1 | 126 aggregate[author_key_cleaner(cs.author)][k]["commits"] = 1 |
125 aggregate[author_key_cleaner(cs.author)][k]["added"] = len(cs.added) | 127 aggregate[author_key_cleaner(cs.author)][k]["added"] = len(cs.added) |
126 aggregate[author_key_cleaner(cs.author)][k]["changed"] = len(cs.changed) | 128 aggregate[author_key_cleaner(cs.author)][k]["changed"] = len(cs.changed) |
127 aggregate[author_key_cleaner(cs.author)][k]["removed"] = len(cs.removed) | 129 aggregate[author_key_cleaner(cs.author)][k]["removed"] = len(cs.removed) |
128 | 130 |
129 else: | 131 else: |
130 if k >= ts_min_y and k <= ts_max_y: | 132 if k >= ts_min_y and k <= ts_max_y or skip_date_limit: |
131 aggregate[author_key_cleaner(cs.author)] = OrderedDict() | 133 aggregate[author_key_cleaner(cs.author)] = OrderedDict() |
132 #aggregate[author_key_cleaner(cs.author)].update(dates_range) | 134 #aggregate[author_key_cleaner(cs.author)].update(dates_range) |
133 aggregate[author_key_cleaner(cs.author)][k] = {} | 135 aggregate[author_key_cleaner(cs.author)][k] = {} |
134 aggregate[author_key_cleaner(cs.author)][k]["commits"] = 1 | 136 aggregate[author_key_cleaner(cs.author)][k]["commits"] = 1 |
135 aggregate[author_key_cleaner(cs.author)][k]["added"] = len(cs.added) | 137 aggregate[author_key_cleaner(cs.author)][k]["added"] = len(cs.added) |
143 overview_aggregate[k] = 1 | 145 overview_aggregate[k] = 1 |
144 | 146 |
145 overview_data = [] | 147 overview_data = [] |
146 for k, v in overview_aggregate.items(): | 148 for k, v in overview_aggregate.items(): |
147 overview_data.append([k, v]) | 149 overview_data.append([k, v]) |
150 overview_data = sorted(overview_data, key=itemgetter(0)) | |
148 data = {} | 151 data = {} |
149 for author in aggregate: | 152 for author in aggregate: |
150 data[author] = {"label":author, | 153 commit_data = sorted([{"time":x, |
151 "data":[{"time":x, | |
152 "commits":aggregate[author][x]['commits'], | 154 "commits":aggregate[author][x]['commits'], |
153 "added":aggregate[author][x]['added'], | 155 "added":aggregate[author][x]['added'], |
154 "changed":aggregate[author][x]['changed'], | 156 "changed":aggregate[author][x]['changed'], |
155 "removed":aggregate[author][x]['removed'], | 157 "removed":aggregate[author][x]['removed'], |
156 } for x in aggregate[author]], | 158 } for x in aggregate[author]], |
159 key=itemgetter('time')) | |
160 | |
161 data[author] = {"label":author, | |
162 "data":commit_data, | |
157 "schema":["commits"] | 163 "schema":["commits"] |
158 } | 164 } |
159 | 165 |
160 if not data: | 166 if not data: |
161 data[author_key_cleaner(repo.contact)] = { | 167 data[author_key_cleaner(repo.contact)] = { |