]> piware.de Git - bin.git/commitdiff
workitems: add by-assignee report to HTML output
authormartin@piware.de <>
Tue, 24 Nov 2009 16:34:35 +0000 (17:34 +0100)
committermartin@piware.de <>
Tue, 24 Nov 2009 16:34:35 +0000 (17:34 +0100)
workitems.py

index db89f51525c203cebe69890912edf9fd4444cebd..7b22e60111fdf07fa49d9382c6feb3534418b4ca 100755 (executable)
@@ -308,6 +308,30 @@ def blueprint_completion(db):
 
     return data
 
+def assignee_completion(db):
+    '''Determine current by-assignee completion.
+
+    Return assignee -> [todo, done, postponed] mapping.
+    '''
+    data = {}
+
+    # last date
+    cur = db.cursor()
+    cur.execute('SELECT max(date) FROM work_items')
+    (last_date,) = cur.fetchone()
+
+    index = 0
+    for s in valid_states:
+        cur = db.cursor()
+        cur.execute('SELECT assignee, count(workitem) FROM work_items '
+                'WHERE date=? and status=? GROUP BY assignee',
+                (last_date, s))
+        for (a, num) in cur:
+            data.setdefault(a, [0, 0, 0])[index] = num
+        index += 1
+
+    return data
+
 def text(db):
     '''Print work item completion as text.'''
 
@@ -406,6 +430,27 @@ def html(db):
 
     print '</table>'
 
+    print '''
+<h1>Status by assignee</h1>
+<table>
+  <tr><th>Assignee</th> <th>todo/postponed/done</th> <th>Completion</th></tr>
+'''
+    data = assignee_completion(db)
+
+    completion = []
+    for (a, (todo, done, postponed)) in data.iteritems():
+        completion.append((a,
+            int(float(postponed+done)/(todo+done+postponed)*100 + 0.5)))
+
+    completion.sort(key=lambda k: k[0], reverse=False)
+
+    for (a, percent) in completion:
+        url = '%s/~%s/+specs?role=assignee' % (blueprints_base_url, a)
+        print '  <tr><td><a href="%s">%s</a></td> <td>%i/%i/%i</td> <td>%i%%</td></tr>' % (
+                url, a, data[a][0], data[a][2],
+                data[a][1], percent)
+    print '</table>'
+
     print '</body></html>'
 
 def import_moin(db, urls):