diff options
author | Dan McGee <dan@archlinux.org> | 2010-01-31 15:19:12 -0600 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2010-01-31 15:19:12 -0600 |
commit | f58b354a037d2c46fd8db9320f8ba29c9e014436 (patch) | |
tree | 05aaea7bcd1a055af9d873482a40b7ecdc44a082 /packages/views.py | |
parent | e0eed01914752ee98d50aeab748f71b24df94dc6 (diff) |
Use select_related() to make a few more places more performant
Especially when looking at packages, we always want the arch and repo.
Another big hunk of changes deals with the very inefficient signoffs code.
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'packages/views.py')
-rw-r--r-- | packages/views.py | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/packages/views.py b/packages/views.py index aa66271f..28d458a0 100644 --- a/packages/views.py +++ b/packages/views.py @@ -190,13 +190,18 @@ def unflag(request, pkgid): @permission_required('main.change_package') def signoffs(request): - packages = Package.objects.filter(repo__name="Testing").order_by("pkgname") + packages = Package.objects.select_related('arch', 'repo', 'signoffs').filter(repo__name__endswith="Testing").order_by("pkgname") package_list = [] - other_packages = Package.objects.exclude(repo__name="Testing") + + q_pkgname = Package.objects.filter(repo__name__endswith="Testing").values('pkgname').distinct().query + package_repos = Package.objects.values('pkgname', 'repo__name').exclude(repo__name__endswith="Testing").filter(pkgname__in=q_pkgname) + pkgtorepo = dict() + for pr in package_repos: + pkgtorepo[pr['pkgname']] = pr['repo__name'] + for package in packages: - other_package = other_packages.filter(pkgname=package.pkgname) - if len(other_package): - repo = other_package[0].repo.name + if package.pkgname in pkgtorepo: + repo = pkgtorepo[package.pkgname] else: repo = "Unknown" package_list.append((package, repo)) |