comparison pylons_app/controllers/summary.py @ 410:9a7ae16ff53e

fixes translations, style updates. Added some extra info to activity graph
author Marcin Kuzminski <marcin@python-works.com>
date Wed, 18 Aug 2010 16:24:27 +0200
parents b153a51b1d3b
children cbfb853a0a4c
comparison
equal deleted inserted replaced
409:9b6c1de4ce9e 410:9a7ae16ff53e
75 #graph range 75 #graph range
76 td = datetime.today() + timedelta(days=1) 76 td = datetime.today() + timedelta(days=1)
77 y = td.year 77 y = td.year
78 m = td.month 78 m = td.month
79 d = td.day 79 d = td.day
80 c.ts_min = mktime((y, (td - timedelta(days=calendar.mdays[m] - 1)).month, d, 0, 0, 0, 0, 0, 0,)) 80 c.ts_min = mktime((y, (td - timedelta(days=calendar.mdays[m] - 1)).month,
81 d, 0, 0, 0, 0, 0, 0,))
81 c.ts_max = mktime((y, m, d, 0, 0, 0, 0, 0, 0,)) 82 c.ts_max = mktime((y, m, d, 0, 0, 0, 0, 0, 0,))
82 83
83 84
84 def author_key_cleaner(k): 85 def author_key_cleaner(k):
85 k = person(k) 86 k = person(k)
91 timetupple = [int(x) for x in k.split('-')] 92 timetupple = [int(x) for x in k.split('-')]
92 timetupple.extend([0 for _ in xrange(6)]) 93 timetupple.extend([0 for _ in xrange(6)])
93 k = mktime(timetupple) 94 k = mktime(timetupple)
94 if aggregate.has_key(author_key_cleaner(cs.author)): 95 if aggregate.has_key(author_key_cleaner(cs.author)):
95 if aggregate[author_key_cleaner(cs.author)].has_key(k): 96 if aggregate[author_key_cleaner(cs.author)].has_key(k):
96 aggregate[author_key_cleaner(cs.author)][k] += 1 97 aggregate[author_key_cleaner(cs.author)][k]["commits"] += 1
98 aggregate[author_key_cleaner(cs.author)][k]["added"] += len(cs.added)
99 aggregate[author_key_cleaner(cs.author)][k]["changed"] += len(cs.changed)
100 aggregate[author_key_cleaner(cs.author)][k]["removed"] += len(cs.removed)
101
97 else: 102 else:
98 #aggregate[author_key_cleaner(cs.author)].update(dates_range) 103 #aggregate[author_key_cleaner(cs.author)].update(dates_range)
99 if k >= c.ts_min and k <= c.ts_max: 104 if k >= c.ts_min and k <= c.ts_max:
100 aggregate[author_key_cleaner(cs.author)][k] = 1 105 aggregate[author_key_cleaner(cs.author)][k] = {}
106 aggregate[author_key_cleaner(cs.author)][k]["commits"] = 1
107 aggregate[author_key_cleaner(cs.author)][k]["added"] = len(cs.added)
108 aggregate[author_key_cleaner(cs.author)][k]["changed"] = len(cs.changed)
109 aggregate[author_key_cleaner(cs.author)][k]["removed"] = len(cs.removed)
110
101 else: 111 else:
102 if k >= c.ts_min and k <= c.ts_max: 112 if k >= c.ts_min and k <= c.ts_max:
103 aggregate[author_key_cleaner(cs.author)] = OrderedDict() 113 aggregate[author_key_cleaner(cs.author)] = OrderedDict()
104 #aggregate[author_key_cleaner(cs.author)].update(dates_range) 114 #aggregate[author_key_cleaner(cs.author)].update(dates_range)
105 aggregate[author_key_cleaner(cs.author)][k] = 1 115 aggregate[author_key_cleaner(cs.author)][k] = {}
116 aggregate[author_key_cleaner(cs.author)][k]["commits"] = 1
117 aggregate[author_key_cleaner(cs.author)][k]["added"] = len(cs.added)
118 aggregate[author_key_cleaner(cs.author)][k]["changed"] = len(cs.changed)
119 aggregate[author_key_cleaner(cs.author)][k]["removed"] = len(cs.removed)
106 120
107 d = '' 121 d = ''
108 tmpl0 = u""""%s":%s""" 122 tmpl0 = u""""%s":%s"""
109 tmpl1 = u"""{label:"%s",data:%s},""" 123 tmpl1 = u"""{label:"%s",data:%s,schema:["commits"]},"""
110 for author in aggregate: 124 for author in aggregate:
125
111 d += tmpl0 % (author.decode('utf8'), 126 d += tmpl0 % (author.decode('utf8'),
112 tmpl1 \ 127 tmpl1 \
113 % (author.decode('utf8'), 128 % (author.decode('utf8'),
114 [[x, aggregate[author][x]] for x in aggregate[author]])) 129 [{"time":x,
130 "commits":aggregate[author][x]['commits'],
131 "added":aggregate[author][x]['added'],
132 "changed":aggregate[author][x]['changed'],
133 "removed":aggregate[author][x]['removed'],
134 } for x in aggregate[author]]))
115 if d == '': 135 if d == '':
116 d = '"%s":{label:"%s",data:[[0,1],]}' \ 136 d = '"%s":{label:"%s",data:[[0,1],]}' \
117 % (author_key_cleaner(repo.contact), 137 % (author_key_cleaner(repo.contact),
118 author_key_cleaner(repo.contact)) 138 author_key_cleaner(repo.contact))
119 return d 139 return d