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
=== modified file 'workitems.py'
--- workitems.py 2009-11-30 15:48:18 +0000
+++ workitems.py 2009-12-03 14:25:19 +0000
@@ -349,7 +349,8 @@
349def assignee_completion(db):349def assignee_completion(db):
350 '''Determine current by-assignee completion.350 '''Determine current by-assignee completion.
351351
352 Return assignee -> [todo, done, postponed] mapping.352 Return assignee -> [todo, done, postponed] mapping. Each of
353 todo/done/postponed is a list of [blueprint, workitem].
353 '''354 '''
354 data = {}355 data = {}
355356
@@ -361,11 +362,11 @@
361 index = 0362 index = 0
362 for s in valid_states:363 for s in valid_states:
363 cur = db.cursor()364 cur = db.cursor()
364 cur.execute('SELECT assignee, count(workitem) FROM work_items '365 cur.execute('SELECT assignee, blueprint, workitem FROM work_items '
365 'WHERE date=? and status=? GROUP BY assignee',366 'WHERE date=? and status=?',
366 (last_date, s))367 (last_date, s))
367 for (a, num) in cur:368 for (a, bp, item) in cur:
368 data.setdefault(a, [0, 0, 0])[index] = num369 data.setdefault(a, [[], [], []])[index].append([bp, item])
369 index += 1370 index += 1
370371
371 return data372 return data
@@ -417,6 +418,13 @@
417 entry.get('postponed', 0))418 entry.get('postponed', 0))
418 d += datetime.timedelta(days=1)419 d += datetime.timedelta(days=1)
419420
421def html_format_blueprint(bp):
422 if bp.startswith('http:') or bp.startswith('https:'):
423 url = bp
424 else:
425 url = '%s/ubuntu/+spec/%s' % (blueprints_base_url, escape(bp))
426 return '<a href="%s">%s</a>' % (url, escape(bp))
427
420def html_format_priority(priority):428def html_format_priority(priority):
421 prio_colors = {429 prio_colors = {
422 'Undefined': 'gray',430 'Undefined': 'gray',
@@ -448,6 +456,7 @@
448 border-width: 3px; padding-right: 10px; }456 border-width: 3px; padding-right: 10px; }
449 table td { text-align: left; border-style: none none dotted none; 457 table td { text-align: left; border-style: none none dotted none;
450 border-width: 1px; padding-right: 10px; }458 border-width: 1px; padding-right: 10px; }
459 table#byworkitem td { vertical-align: top; }
451460
452 a { color: blue; }461 a { color: blue; }
453 </style>462 </style>
@@ -473,12 +482,9 @@
473 completion.sort(key=lambda k: k[1], reverse=True)482 completion.sort(key=lambda k: k[1], reverse=True)
474483
475 for (bp, percent) in completion:484 for (bp, percent) in completion:
476 if bp.startswith('http:') or bp.startswith('https:'):485 bp_html = html_format_blueprint(bp)
477 url = bp486 print ' <tr><td>%s</td> <td>%i/%i/%i</td> <td>%i%%</td> <td>%s</td> <td>%s</td></tr>' % (
478 else:487 bp_html, data[bp][0], data[bp][2],
479 url = '%s/ubuntu/+spec/%s' % (blueprints_base_url, escape(bp))
480 print ' <tr><td><a href="%s">%s</a></td> <td>%i/%i/%i</td> <td>%i%%</td> <td>%s</td> <td>%s</td></tr>' % (
481 url, escape(bp), data[bp][0], data[bp][2],
482 data[bp][1], percent,488 data[bp][1], percent,
483 html_format_priority(data[bp][-1]),489 html_format_priority(data[bp][-1]),
484 escape(data[bp][-2]))490 escape(data[bp][-2]))
@@ -494,16 +500,58 @@
494500
495 completion = []501 completion = []
496 for (a, (todo, done, postponed)) in data.iteritems():502 for (a, (todo, done, postponed)) in data.iteritems():
503 todo_len = len(todo)
504 postponed_len = len(postponed)
505 done_len = len(done)
497 completion.append((a,506 completion.append((a,
498 int(float(postponed+done)/(todo+done+postponed)*100 + 0.5)))507 int(float(postponed_len+done_len)/
508 (todo_len+done_len+postponed_len)*100 + 0.5)))
499509
500 completion.sort(key=lambda k: k[0], reverse=False)510 completion.sort(key=lambda k: k[0], reverse=False)
501511
502 for (a, percent) in completion:512 for (a, percent) in completion:
503 url = '%s/~%s/+specs?role=assignee' % (blueprints_base_url, a)513 url = '%s/~%s/+specs?role=assignee' % (blueprints_base_url, a)
504 print ' <tr><td><a href="%s">%s</a></td> <td>%i/%i/%i</td> <td>%i%%</td></tr>' % (514 print ' <tr><td><a href="%s">%s</a></td> <td>%i/%i/%i</td> <td>%i%%</td></tr>' % (
505 url, escape(a), data[a][0], data[a][2],515 url, escape(a), len(data[a][0]), len(data[a][2]),
506 data[a][1], percent)516 len(data[a][1]), percent)
517 print '</table>'
518
519 print '''
520<h1>Status by work item</h1>
521<table id="byworkitem">
522 <tr><th>Assignee</th> <th>Status</th> <th>Blueprint</th> <th>Work item</th></tr>
523'''
524 # data is still assignee_completion(db), from above
525 completion = data.items()
526 completion.sort(key=lambda k: k[0], reverse=False)
527
528 for (a, (todo, done, postponed)) in completion:
529 todo.sort(key=lambda k: k[0])
530 postponed.sort(key=lambda k: k[0])
531 done.sort(key=lambda k: k[0])
532 todo_len = len(todo)
533 postponed_len = len(postponed)
534 done_len = len(done)
535 url = '%s/~%s/+specs?role=assignee' % (blueprints_base_url, a)
536 rows = ['<td rowspan="%s">todo</td>' % todo_len,
537 '<td rowspan="%s">postponed</td>' % postponed_len,
538 '<td rowspan="%s">done</td>' % done_len]
539 i = 0
540 printed_assignee = False
541 for status in (todo, postponed, done):
542 printed_status = False
543 for (bp, item) in status:
544 print ' <tr>',
545 if not printed_assignee:
546 print '<td rowspan="%s"><a href="%s">%s</a></td> ' % (
547 todo_len+postponed_len+done_len, url, escape(a)),
548 printed_assignee = True
549 if not printed_status:
550 print rows[i]
551 printed_status = True
552 print '<td>%s</td> <td>%s</td></tr>' % (
553 html_format_blueprint(bp), item)
554 i += 1
507 print '</table>'555 print '</table>'
508556
509 print '</body></html>'557 print '</body></html>'

Subscribers

People subscribed via source and target branches

to all changes: