+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
+