diff options
author | Evangelos Foutras <foutrelis@gmail.com> | 2010-01-31 06:55:43 +0100 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2010-01-31 20:44:55 +0100 |
commit | 343786f8cdbf9577e4b6f1ca42b94d4296631675 (patch) | |
tree | 9362a13f6457810c555f93d777a70e7c952e38fe /main | |
parent | 09a3a08144fd14fcd905cdf3e86dcc240458040c (diff) | |
download | archweb-343786f8cdbf9577e4b6f1ca42b94d4296631675.tar.gz archweb-343786f8cdbf9577e4b6f1ca42b94d4296631675.tar.xz |
Reintroduce optimized code for Todo listings
Now that maintainer is nullable, Django will use a LEFT OUTER JOIN with
this code, so orphan packages won't be omitted.
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'main')
-rw-r--r-- | main/models.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/main/models.py b/main/models.py index 98547a3..d0c9c5c 100644 --- a/main/models.py +++ b/main/models.py @@ -303,10 +303,10 @@ class Todolist(models.Model): @property def packages(self): - # TODO: bug here, because we do foreign keys all wrong the join query fucks up when it - # can't find a foreign key that is missing values, e.g. maintainer == 0. - # Once this is fixed, we can remove the depth argument. - return TodolistPkg.objects.select_related(depth=1).filter(list=self).order_by('pkg') + # select_related() does not use LEFT OUTER JOIN for nullable ForeignKey + # fields. That is why we need to explicitly list the ones we want. + return TodolistPkg.objects.select_related( + 'pkg__repo', 'pkg__arch', 'pkg__maintainer').filter(list=self).order_by('pkg') @property def package_names(self): |