summaryrefslogtreecommitdiff
path: root/devel/views.py
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-12-09 09:30:18 -0600
committerDan McGee <dan@archlinux.org>2011-12-09 09:30:18 -0600
commitd198137d718a5dfcaacedc3e2e3adf86c3192cd7 (patch)
treec699e89c7ae3091949c664f3c486abf8c018181f /devel/views.py
parent73cd4adf9ff2b38124501fba1a7d9800e4c1f0d0 (diff)
Prefilter packages when looking up uncompressed man/info pages
This vastly speeds up the reports if you just want to look at your own packages and not the complete list, especially if the list of packages you maintain is relatively short. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'devel/views.py')
-rw-r--r--devel/views.py42
1 files changed, 23 insertions, 19 deletions
diff --git a/devel/views.py b/devel/views.py
index 59e2b6cb..79272c98 100644
--- a/devel/views.py
+++ b/devel/views.py
@@ -6,7 +6,7 @@ from django.contrib.auth.models import User, Group
from django.contrib.sites.models import Site
from django.core.mail import send_mail
from django.db import transaction
-from django.db.models import F, Q
+from django.db.models import F
from django.http import Http404
from django.shortcuts import get_object_or_404
from django.template import loader, Context
@@ -150,6 +150,15 @@ def report(request, report, username=None):
packages = Package.objects.normal()
names = attrs = user = None
+ if username:
+ user = get_object_or_404(User, username=username, is_active=True)
+ maintained = PackageRelation.objects.filter(user=user,
+ type=PackageRelation.MAINTAINER).values('pkgbase')
+ packages = packages.filter(pkgbase__in=maintained)
+
+ maints = User.objects.filter(id__in=PackageRelation.objects.filter(
+ type=PackageRelation.MAINTAINER).values('user'))
+
if report == 'old':
title = 'Packages last built more than two years ago'
cutoff = datetime.utcnow() - timedelta(days=365 * 2)
@@ -192,20 +201,24 @@ def report(request, report, username=None):
package.compress_type = package.filename.split('.')[-1]
elif report == 'uncompressed-man':
title = 'Packages with uncompressed manpages'
- # magic going on here! Checking for all '.1'...'.9' extensions
- invalid_endings = [Q(filename__endswith='.%d' % n) for n in range(1,10)]
- invalid_endings.append(Q(filename__endswith='.n'))
- bad_files = PackageFile.objects.filter(Q(directory__contains='man') & (
- reduce(operator.or_, invalid_endings))
- ).values_list('pkg_id', flat=True).distinct()
+ # checking for all '.0'...'.9' + '.n' extensions
+ bad_files = PackageFile.objects.filter(directory__contains='/man/',
+ filename__regex=r'\.[0-9n]').exclude(filename__endswith='.gz')
+ if username:
+ pkg_ids = set(packages.values_list('id', flat=True))
+ bad_files = bad_files.filter(pkg__in=pkg_ids)
+ bad_files = bad_files.values_list('pkg_id', flat=True).distinct()
packages = packages.filter(id__in=set(bad_files))
elif report == 'uncompressed-info':
title = 'Packages with uncompressed infopages'
- # we don't worry abut looking for '*.info-1', etc., given that an
+ # we don't worry about looking for '*.info-1', etc., given that an
# uncompressed root page probably exists in the package anyway
bad_files = PackageFile.objects.filter(directory__endswith='/info/',
- filename__endswith='.info').values_list(
- 'pkg_id', flat=True).distinct()
+ filename__endswith='.info')
+ if username:
+ pkg_ids = set(packages.values_list('id', flat=True))
+ bad_files = bad_files.filter(pkg__in=pkg_ids)
+ bad_files = bad_files.values_list('pkg_id', flat=True).distinct()
packages = packages.filter(id__in=set(bad_files))
elif report == 'unneeded-orphans':
title = 'Orphan packages required by no other packages'
@@ -217,15 +230,6 @@ def report(request, report, username=None):
else:
raise Http404
- if username:
- user = get_object_or_404(User, username=username, is_active=True)
- maintained = PackageRelation.objects.filter(user=user,
- type=PackageRelation.MAINTAINER).values('pkgbase')
- packages = packages.filter(pkgbase__in=maintained)
-
- maints = User.objects.filter(id__in=PackageRelation.objects.filter(
- type=PackageRelation.MAINTAINER).values('user'))
-
context = {
'all_maintainers': maints,
'title': title,