diff options
author | Dan McGee <dan@archlinux.org> | 2012-12-28 00:27:20 -0600 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2012-12-28 14:48:29 -0600 |
commit | c8ece67cec9c421ac0c711554edd34f022623b45 (patch) | |
tree | a894e1e82df91fda22807efbc3519bd18e12f321 /todolists/utils.py | |
parent | c7658ca4cd0f89969086fed172519ca2097270ba (diff) |
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.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/todolists/utils.py b/todolists/utils.py index 03c47931..d084c645 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 |