summaryrefslogtreecommitdiffstats
path: root/todolists/utils.py
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2012-12-28 07:27:20 +0100
committerDan McGee <dan@archlinux.org>2012-12-28 21:48:29 +0100
commitc8ece67cec9c421ac0c711554edd34f022623b45 (patch)
treea894e1e82df91fda22807efbc3519bd18e12f321 /todolists/utils.py
parentc7658ca4cd0f89969086fed172519ca2097270ba (diff)
downloadarchweb-c8ece67cec9c421ac0c711554edd34f022623b45.tar.gz
archweb-c8ece67cec9c421ac0c711554edd34f022623b45.tar.xz
Convert to using new todolist models everywhere
This is a rather widespread set of changes converting usage to the new todo list and todo list package model recently introduced. The data migration is not included in this commit. After this commit, the old model should no longer be referenced anywhere. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'todolists/utils.py')
-rw-r--r--todolists/utils.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/todolists/utils.py b/todolists/utils.py
index 03c4793..d084c64 100644
--- a/todolists/utils.py
+++ b/todolists/utils.py
@@ -1,26 +1,26 @@
from django.db import connections, router
from django.db.models import Count
-from main.models import Todolist, TodolistPkg
+from .models import Todolist, TodolistPackage
def todo_counts():
sql = """
-SELECT list_id, count(*), sum(CASE WHEN complete THEN 1 ELSE 0 END)
- FROM todolist_pkgs
- GROUP BY list_id
+SELECT todolist_id, count(*), sum(CASE WHEN status = %s THEN 1 ELSE 0 END)
+ FROM todolists_todolistpackage
+ GROUP BY todolist_id
"""
- database = router.db_for_write(TodolistPkg)
+ database = router.db_for_write(TodolistPackage)
connection = connections[database]
cursor = connection.cursor()
- cursor.execute(sql)
+ cursor.execute(sql, [TodolistPackage.COMPLETE])
results = cursor.fetchall()
return {row[0]: (row[1], row[2]) for row in results}
def get_annotated_todolists(incomplete_only=False):
lists = Todolist.objects.all().select_related(
- 'creator').order_by('-date_added')
+ 'creator').order_by('-created')
lookup = todo_counts()
# tag each list with package counts