summaryrefslogtreecommitdiff
path: root/todolists/utils.py
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-04-09 16:29:38 -0500
committerDan McGee <dan@archlinux.org>2011-04-09 16:34:10 -0500
commit064813560c20f53f9fd759d0c4e0f0a6729c8ba6 (patch)
treef1cb259c155896a00659df086e34a6c4d88460f9 /todolists/utils.py
parent842f59d018947ca696cf116e9d1591f2ad83f8a7 (diff)
Show more info about todolists on developer dashboardrelease_2011-04-09
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'todolists/utils.py')
-rw-r--r--todolists/utils.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/todolists/utils.py b/todolists/utils.py
new file mode 100644
index 00000000..894f3f1d
--- /dev/null
+++ b/todolists/utils.py
@@ -0,0 +1,19 @@
+from django.db.models import Count
+
+from main.models import Todolist
+
+def get_annotated_todolists():
+ qs = Todolist.objects.all()
+ lists = qs.select_related('creator').annotate(
+ pkg_count=Count('todolistpkg')).order_by('-date_added')
+ incomplete = qs.filter(todolistpkg__complete=False).annotate(
+ Count('todolistpkg')).values_list('id', 'todolistpkg__count')
+
+ # tag each list with an incomplete package count
+ lookup = dict(incomplete)
+ for todolist in lists:
+ todolist.incomplete_count = lookup.get(todolist.id, 0)
+
+ return lists
+
+# vim: set ts=4 sw=4 et: