summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--devel/views.py3
-rw-r--r--todolists/utils.py8
2 files changed, 7 insertions, 4 deletions
diff --git a/devel/views.py b/devel/views.py
index d2ce65db..39f28a65 100644
--- a/devel/views.py
+++ b/devel/views.py
@@ -49,8 +49,7 @@ def index(request):
todopkgs = todopkgs.filter(pkg__pkgbase__in=inner_q).order_by(
'list__name', 'pkg__pkgname')
- todolists = get_annotated_todolists()
- todolists = [todolist for todolist in todolists if todolist.incomplete_count > 0]
+ todolists = get_annotated_todolists(incomplete_only=True)
signoffs = sorted(get_signoff_groups(user=request.user),
key=operator.attrgetter('pkgbase'))
diff --git a/todolists/utils.py b/todolists/utils.py
index 24101e86..94f39f71 100644
--- a/todolists/utils.py
+++ b/todolists/utils.py
@@ -3,7 +3,7 @@ from django.db.models import Count
from main.models import Todolist
-def get_annotated_todolists():
+def get_annotated_todolists(incomplete_only=False):
qs = Todolist.objects.all()
lists = qs.select_related('creator').defer(
'creator__email', 'creator__password', 'creator__is_staff',
@@ -13,8 +13,12 @@ def get_annotated_todolists():
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)
+
+ if incomplete_only:
+ lists = lists.filter(id__in=lookup.keys())
+
+ # tag each list with an incomplete package count
for todolist in lists:
todolist.incomplete_count = lookup.get(todolist.id, 0)