diff options
author | Nicolás Reynolds <fauno@kiwwwi.com.ar> | 2011-08-03 16:05:35 -0300 |
---|---|---|
committer | Nicolás Reynolds <fauno@kiwwwi.com.ar> | 2011-08-03 16:05:35 -0300 |
commit | fbd23db51b7160a308cd88e407e676994eb08b10 (patch) | |
tree | e3816cc4e3f0ee07539fb4464b2d886a43ecc318 /packages/utils.py | |
parent | a8b2fc84ba96c83ec1addf89ac04608fbf572705 (diff) | |
parent | 0f6c80e9a36bc5770e95543b4374c5ace4383cf5 (diff) |
Merge branch 'master' of git://projects.archlinux.org/archweb
Conflicts:
packages/urls.py
templates/packages/details.html
Diffstat (limited to 'packages/utils.py')
-rw-r--r-- | packages/utils.py | 46 |
1 files changed, 33 insertions, 13 deletions
diff --git a/packages/utils.py b/packages/utils.py index af4675bb..c8c1f8a6 100644 --- a/packages/utils.py +++ b/packages/utils.py @@ -1,11 +1,12 @@ +from collections import defaultdict +from operator import itemgetter + from django.db import connection from django.db.models import Count, Max -from operator import itemgetter - from main.models import Package from main.utils import cache_function -from .models import PackageGroup, PackageRelation +from .models import PackageGroup, PackageRelation, Signoff @cache_function(300) def get_group_info(include_arches=None): @@ -92,21 +93,16 @@ SELECT p.id, q.id WHERE p.arch_id IN (%s, %s) AND ( q.id IS NULL - OR - p.pkgver != q.pkgver - OR - p.pkgrel != q.pkgrel - OR - p.epoch != q.epoch + OR p.pkgver != q.pkgver + OR p.pkgrel != q.pkgrel + OR p.epoch != q.epoch ) """ cursor = connection.cursor() cursor.execute(sql, [arch_a.id, arch_b.id]) results = cursor.fetchall() - to_fetch = [] - for row in results: - # column A will always have a value, column B might be NULL - to_fetch.append(row[0]) + # column A will always have a value, column B might be NULL + to_fetch = [row[0] for row in results] # fetch all of the necessary packages pkgs = Package.objects.normal().in_bulk(to_fetch) # now build a list of tuples containing differences @@ -152,4 +148,28 @@ SELECT DISTINCT id id__in=to_fetch) return relations +def get_current_signoffs(): + '''Returns a mapping of pkgbase -> signoff objects.''' + sql = """ +SELECT DISTINCT s.id + FROM packages_signoff s + JOIN packages p ON ( + s.pkgbase = p.pkgbase + AND s.pkgver = p.pkgver + AND s.pkgrel = p.pkgrel + AND s.epoch = p.epoch + AND s.arch_id = p.arch_id + AND s.repo_id = p.repo_id + ) + JOIN repos r ON p.repo_id = r.id + WHERE r.testing = %s +""" + cursor = connection.cursor() + cursor.execute(sql, [True]) + results = cursor.fetchall() + # fetch all of the returned signoffs by ID + to_fetch = [row[0] for row in results] + signoffs = Signoff.objects.select_related('user').in_bulk(to_fetch) + return signoffs.values() + # vim: set ts=4 sw=4 et: |