summaryrefslogtreecommitdiff
path: root/packages/utils.py
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2013-01-25 09:54:24 -0700
committerDan McGee <dan@archlinux.org>2013-01-25 09:54:24 -0700
commit4244ff7a42566949f8ee85e922ed48f4a80407f7 (patch)
tree21caf4d67aa36d06c6a921608901ad059752e744 /packages/utils.py
parentf9252df1138ae388168cf76cb3d654a2abbce4ec (diff)
parentdc6cc49f6f876983f76f5f8c05a2285801f27ea0 (diff)
Merge branch 'on-the-plane'release_2013-01-25
Diffstat (limited to 'packages/utils.py')
-rw-r--r--packages/utils.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/packages/utils.py b/packages/utils.py
index a72404f4..49aeb8ce 100644
--- a/packages/utils.py
+++ b/packages/utils.py
@@ -6,6 +6,7 @@ import re
from django.core.serializers.json import DjangoJSONEncoder
from django.db import connection
from django.db.models import Count, Max, F
+from django.db.models.query import QuerySet
from django.contrib.auth.models import User
from main.models import Package, PackageFile, Arch, Repo
@@ -253,8 +254,11 @@ def attach_maintainers(packages):
'''Given a queryset or something resembling it of package objects, find all
the maintainers and attach them to the packages to prevent N+1 query
cascading.'''
- packages = list(packages)
- pkgbases = {p.pkgbase for p in packages if p is not None}
+ if isinstance(packages, QuerySet):
+ pkgbases = packages.values('pkgbase')
+ else:
+ packages = list(packages)
+ pkgbases = {p.pkgbase for p in packages if p is not None}
rels = PackageRelation.objects.filter(type=PackageRelation.MAINTAINER,
pkgbase__in=pkgbases).values_list(
'pkgbase', 'user_id').order_by().distinct()