Commit 3283144d authored by Jelle van der Waa's avatar Jelle van der Waa 🚧
Browse files

packages: remove unused get_differences_info

The view which used get_differences_info was removed in
373a426c but didn't clean up the utility functions.
parent 94c9b901
from collections import defaultdict
from itertools import chain
from operator import attrgetter, itemgetter
from operator import itemgetter
import re
from django.core.serializers.json import DjangoJSONEncoder
......@@ -119,59 +119,6 @@ def __hash__(self):
return hash(self.__key())
def get_differences_info(arch_a, arch_b):
# This is a monster. Join packages against itself, looking for packages in
# our non-'any' architectures only, and not having a corresponding package
# entry in the other table (or having one with a different pkgver). We will
# then go and fetch all of these packages from the database and display
# them later using normal ORM models.
sql = """
FROM packages p
LEFT JOIN packages q
ON (
p.pkgname = q.pkgname
AND p.repo_id = q.repo_id
AND p.arch_id != q.arch_id
AND !=
WHERE p.arch_id IN (%s, %s)
OR p.pkgver != q.pkgver
OR p.pkgrel != q.pkgrel
OR p.epoch != q.epoch
cursor = connection.cursor()
cursor.execute(sql, [,])
results = cursor.fetchall()
# 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 set containing differences
differences = set()
for row in results:
pkg_a = pkgs.get(row[0])
pkg_b = pkgs.get(row[1])
# We want arch_a to always appear first
# pkg_a should never be None
if pkg_a.arch == arch_a:
item = Difference(pkg_a.pkgname, pkg_a.repo, pkg_a, pkg_b)
# pkg_b can be None in this case, so be careful
name = pkg_a.pkgname if pkg_a else pkg_b.pkgname
repo = pkg_a.repo if pkg_a else pkg_b.repo
item = Difference(name, repo, pkg_b, pkg_a)
# now sort our list by repository, package name
key_func = attrgetter('', 'pkgname')
differences = sorted(differences, key=key_func)
return differences
def multilib_differences():
# Query for checking multilib out of date-ness
if database_vendor(Package) == 'sqlite':
......@@ -11,14 +11,13 @@
from django.views.decorators.cache import cache_control
from django.views.decorators.http import require_safe, require_POST
from main.models import Package, Arch
from main.models import Package
from ..models import PackageRelation
from ..utils import (get_differences_info,
multilib_differences, get_wrong_permissions)
from ..utils import multilib_differences, get_wrong_permissions
# make other views available from this same package
from .display import (details, groups, group_details, files, details_json,
files_json, download)
files_json, download)
from .flag import flaghelp, flag, flag_confirmed, unflag, unflag_all
from .search import search_json
from .signoff import signoffs, signoff_package, signoff_options, signoffs_json
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment