diff options
author | Dan McGee <dan@archlinux.org> | 2011-06-15 22:50:14 +0200 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2011-06-15 22:50:14 +0200 |
commit | 4a9b6867a3a2786435316ab7deefa54257bb931d (patch) | |
tree | 3b0cfc08238dcf6b67dac16b8c35bc26b14b213a /public | |
parent | eb231660b017eab886ecd98828bf0295e36a1112 (diff) | |
download | archweb-4a9b6867a3a2786435316ab7deefa54257bb931d.tar.gz archweb-4a9b6867a3a2786435316ab7deefa54257bb931d.tar.xz |
Refactor common select_related into manager method
For a Package object query, we almost always did .select_related('arch',
'repo). Refactor this into the manager as a 'normal()' method so we can
avoid sprinkling the same logic everywhere.
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'public')
-rw-r--r-- | public/utils.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/public/utils.py b/public/utils.py index fd29a84..0be3eba 100644 --- a/public/utils.py +++ b/public/utils.py @@ -1,6 +1,6 @@ from operator import attrgetter -from main.models import Arch, Package +from main.models import Arch, Package, Repo from main.utils import cache_function class RecentUpdate(object): @@ -57,8 +57,8 @@ def get_recent_updates(number=15): # grab a few extra so we can hopefully catch everything we need fetch = number * 6 for arch in Arch.objects.all(): - pkgs += list(Package.objects.select_related( - 'arch', 'repo').filter(arch=arch).order_by('-last_update')[:fetch]) + pkgs += list(Package.objects.normal().filter( + arch=arch).order_by('-last_update')[:fetch]) pkgs.sort(key=attrgetter('last_update')) updates = [] |