diff options
author | Luke Shumaker <LukeShu@sbcglobal.net> | 2012-11-14 16:08:04 -0500 |
---|---|---|
committer | Luke Shumaker <LukeShu@sbcglobal.net> | 2012-11-14 16:08:04 -0500 |
commit | 87520a593377858f2aa53d7f297dfc52f6fe397f (patch) | |
tree | e1183fdd927301a23071b71b1b032528b9b043d5 /packages/utils.py | |
parent | 3fe4b2189cd4c9741eebc0fa6ac131a5663be535 (diff) | |
parent | 96fecb1079a1ad4a2b574616bc6611678fa53dc8 (diff) |
Merge commit '96fecb1' (Multilib differences report)
Conflicts:
packages/views/__init__.py
templates/packages/differences.html
Diffstat (limited to 'packages/utils.py')
-rw-r--r-- | packages/utils.py | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/packages/utils.py b/packages/utils.py index 82d47bc7..5d0d0250 100644 --- a/packages/utils.py +++ b/packages/utils.py @@ -1,4 +1,5 @@ from collections import defaultdict +from itertools import chain from operator import itemgetter from django.db import connection @@ -63,6 +64,7 @@ def get_split_packages_info(): split['repo'] = all_repos[split['repo']] return split_pkgs + class Difference(object): def __init__(self, pkgname, repo, pkg_a, pkg_b): self.pkgname = pkgname @@ -89,6 +91,7 @@ class Difference(object): return cmp(self.__dict__, other.__dict__) return False + @cache_function(300) def get_differences_info(arch_a, arch_b): # This is a monster. Join packages against itself, looking for packages in @@ -147,6 +150,46 @@ SELECT p.id, q.id return differences +def multilib_differences(): + # Query for checking multilib out of date-ness + sql = """ +SELECT ml.id, reg.id + FROM packages ml + JOIN packages reg + ON ( + reg.pkgname = ( + CASE WHEN ml.pkgname LIKE %s + THEN SUBSTRING(ml.pkgname, 7) + WHEN ml.pkgname LIKE %s + THEN SUBSTRING(ml.pkgname FROM 1 FOR CHAR_LENGTH(ml.pkgname) - 9) + ELSE + ml.pkgname + END + ) + AND reg.pkgver != ml.pkgver + ) + JOIN repos r ON reg.repo_id = r.id + WHERE ml.repo_id = %s + AND r.testing = %s + AND r.staging = %s + AND reg.arch_id = %s + ORDER BY ml.last_update +""" + multilib = Repo.objects.get(name__iexact='multilib') + i686 = Arch.objects.get(name='i686') + params = ['lib32-%', '%-multilib', multilib.id, False, False, i686.id] + + cursor = connection.cursor() + cursor.execute(sql, params) + results = cursor.fetchall() + + # fetch all of the necessary packages + to_fetch = set(chain.from_iterable(results)) + pkgs = Package.objects.normal().in_bulk(to_fetch) + + return [(pkgs[ml], pkgs[reg]) for ml, reg in results] + + def get_wrong_permissions(): sql = """ SELECT DISTINCT id |