Merge lp:~cjwatson/launchpad-work-items-tracker/by-work-item into lp:launchpad-work-items-tracker

Proposed by Colin Watson
Status: Merged
Merged at revision: not available
Proposed branch: lp:~cjwatson/launchpad-work-items-tracker/by-work-item
Merge into: lp:launchpad-work-items-tracker
Diff against target: 129 lines (+62/-14)
1 file modified
workitems.py (+62/-14)
To merge this branch: bzr merge lp:~cjwatson/launchpad-work-items-tracker/by-work-item
Reviewer Review Type Date Requested Status
Martin Pitt Pending
Review via email: mp+15602@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'workitems.py'
2--- workitems.py 2009-11-30 15:48:18 +0000
3+++ workitems.py 2009-12-03 14:25:19 +0000
4@@ -349,7 +349,8 @@
5 def assignee_completion(db):
6 '''Determine current by-assignee completion.
7
8- Return assignee -> [todo, done, postponed] mapping.
9+ Return assignee -> [todo, done, postponed] mapping. Each of
10+ todo/done/postponed is a list of [blueprint, workitem].
11 '''
12 data = {}
13
14@@ -361,11 +362,11 @@
15 index = 0
16 for s in valid_states:
17 cur = db.cursor()
18- cur.execute('SELECT assignee, count(workitem) FROM work_items '
19- 'WHERE date=? and status=? GROUP BY assignee',
20+ cur.execute('SELECT assignee, blueprint, workitem FROM work_items '
21+ 'WHERE date=? and status=?',
22 (last_date, s))
23- for (a, num) in cur:
24- data.setdefault(a, [0, 0, 0])[index] = num
25+ for (a, bp, item) in cur:
26+ data.setdefault(a, [[], [], []])[index].append([bp, item])
27 index += 1
28
29 return data
30@@ -417,6 +418,13 @@
31 entry.get('postponed', 0))
32 d += datetime.timedelta(days=1)
33
34+def html_format_blueprint(bp):
35+ if bp.startswith('http:') or bp.startswith('https:'):
36+ url = bp
37+ else:
38+ url = '%s/ubuntu/+spec/%s' % (blueprints_base_url, escape(bp))
39+ return '<a href="%s">%s</a>' % (url, escape(bp))
40+
41 def html_format_priority(priority):
42 prio_colors = {
43 'Undefined': 'gray',
44@@ -448,6 +456,7 @@
45 border-width: 3px; padding-right: 10px; }
46 table td { text-align: left; border-style: none none dotted none;
47 border-width: 1px; padding-right: 10px; }
48+ table#byworkitem td { vertical-align: top; }
49
50 a { color: blue; }
51 </style>
52@@ -473,12 +482,9 @@
53 completion.sort(key=lambda k: k[1], reverse=True)
54
55 for (bp, percent) in completion:
56- if bp.startswith('http:') or bp.startswith('https:'):
57- url = bp
58- else:
59- url = '%s/ubuntu/+spec/%s' % (blueprints_base_url, escape(bp))
60- print ' <tr><td><a href="%s">%s</a></td> <td>%i/%i/%i</td> <td>%i%%</td> <td>%s</td> <td>%s</td></tr>' % (
61- url, escape(bp), data[bp][0], data[bp][2],
62+ bp_html = html_format_blueprint(bp)
63+ print ' <tr><td>%s</td> <td>%i/%i/%i</td> <td>%i%%</td> <td>%s</td> <td>%s</td></tr>' % (
64+ bp_html, data[bp][0], data[bp][2],
65 data[bp][1], percent,
66 html_format_priority(data[bp][-1]),
67 escape(data[bp][-2]))
68@@ -494,16 +500,58 @@
69
70 completion = []
71 for (a, (todo, done, postponed)) in data.iteritems():
72+ todo_len = len(todo)
73+ postponed_len = len(postponed)
74+ done_len = len(done)
75 completion.append((a,
76- int(float(postponed+done)/(todo+done+postponed)*100 + 0.5)))
77+ int(float(postponed_len+done_len)/
78+ (todo_len+done_len+postponed_len)*100 + 0.5)))
79
80 completion.sort(key=lambda k: k[0], reverse=False)
81
82 for (a, percent) in completion:
83 url = '%s/~%s/+specs?role=assignee' % (blueprints_base_url, a)
84 print ' <tr><td><a href="%s">%s</a></td> <td>%i/%i/%i</td> <td>%i%%</td></tr>' % (
85- url, escape(a), data[a][0], data[a][2],
86- data[a][1], percent)
87+ url, escape(a), len(data[a][0]), len(data[a][2]),
88+ len(data[a][1]), percent)
89+ print '</table>'
90+
91+ print '''
92+<h1>Status by work item</h1>
93+<table id="byworkitem">
94+ <tr><th>Assignee</th> <th>Status</th> <th>Blueprint</th> <th>Work item</th></tr>
95+'''
96+ # data is still assignee_completion(db), from above
97+ completion = data.items()
98+ completion.sort(key=lambda k: k[0], reverse=False)
99+
100+ for (a, (todo, done, postponed)) in completion:
101+ todo.sort(key=lambda k: k[0])
102+ postponed.sort(key=lambda k: k[0])
103+ done.sort(key=lambda k: k[0])
104+ todo_len = len(todo)
105+ postponed_len = len(postponed)
106+ done_len = len(done)
107+ url = '%s/~%s/+specs?role=assignee' % (blueprints_base_url, a)
108+ rows = ['<td rowspan="%s">todo</td>' % todo_len,
109+ '<td rowspan="%s">postponed</td>' % postponed_len,
110+ '<td rowspan="%s">done</td>' % done_len]
111+ i = 0
112+ printed_assignee = False
113+ for status in (todo, postponed, done):
114+ printed_status = False
115+ for (bp, item) in status:
116+ print ' <tr>',
117+ if not printed_assignee:
118+ print '<td rowspan="%s"><a href="%s">%s</a></td> ' % (
119+ todo_len+postponed_len+done_len, url, escape(a)),
120+ printed_assignee = True
121+ if not printed_status:
122+ print rows[i]
123+ printed_status = True
124+ print '<td>%s</td> <td>%s</td></tr>' % (
125+ html_format_blueprint(bp), item)
126+ i += 1
127 print '</table>'
128
129 print '</body></html>'

Subscribers

People subscribed via source and target branches

to all changes: