summaryrefslogtreecommitdiffstats
path: root/devel
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2012-04-27 16:24:34 +0200
committerDan McGee <dan@archlinux.org>2012-04-27 16:24:34 +0200
commit80e7d19726a95b40727b7f35b9ad80b436b14b93 (patch)
tree12ba9aa51efb35c3b2bc91cd09913eff3829e5fb /devel
parent4e1e28729f97eb694cdcae2f3fe51b5178963069 (diff)
downloadarchweb-80e7d19726a95b40727b7f35b9ad80b436b14b93.tar.gz
archweb-80e7d19726a95b40727b7f35b9ad80b436b14b93.tar.xz
Dev dashboard performance improvement
Rather than one query per cell in the arches and repos statistics tables, we can group these together up front using Django annotations. This means we only need one query per table. In my local instance with all of the staging repos imported, this reduces the total query count on this page from 56 to 26, a rather marked improvement. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'devel')
-rw-r--r--devel/views.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/devel/views.py b/devel/views.py
index 39f28a6..cf0d8ad 100644
--- a/devel/views.py
+++ b/devel/views.py
@@ -13,7 +13,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
+from django.db.models import F, Count
from django.http import Http404
from django.shortcuts import get_object_or_404
from django.template import loader, Context
@@ -54,6 +54,11 @@ def index(request):
signoffs = sorted(get_signoff_groups(user=request.user),
key=operator.attrgetter('pkgbase'))
+ arches = Arch.objects.all().annotate(
+ total_ct=Count('packages'), flagged_ct=Count('packages__flag_date'))
+ repos = Repo.objects.all().annotate(
+ total_ct=Count('packages'), flagged_ct=Count('packages__flag_date'))
+
maintainers = get_annotated_maintainers()
maintained = PackageRelation.objects.filter(
@@ -70,12 +75,12 @@ def index(request):
page_dict = {
'todos': todolists,
- 'repos': Repo.objects.all(),
- 'arches': Arch.objects.all(),
+ 'arches': arches,
+ 'repos': repos,
'maintainers': maintainers,
'orphan': orphan,
- 'flagged' : flagged,
- 'todopkgs' : todopkgs,
+ 'flagged': flagged,
+ 'todopkgs': todopkgs,
'signoffs': signoffs
}