diff options
Diffstat (limited to 'public')
-rw-r--r-- | public/utils.py | 14 | ||||
-rw-r--r-- | public/views.py | 2 |
2 files changed, 10 insertions, 6 deletions
diff --git a/public/utils.py b/public/utils.py index c92cb264..2801c939 100644 --- a/public/utils.py +++ b/public/utils.py @@ -1,4 +1,6 @@ -from main.models import Arch, Repo, Package +from operator import attrgetter + +from main.models import Arch, Package from main.utils import cache_function @cache_function(300) @@ -7,18 +9,20 @@ def get_recent_updates(): # want to try and eliminate cross-architecture wasted space. Pull enough # packages that we can later do some screening and trim out the fat. pkgs = [] - for a in Arch.objects.all(): + for arch in Arch.objects.all(): # grab a few extra so we can hopefully catch everything we need - pkgs += list(Package.objects.select_related('arch', 'repo').filter(arch=a).order_by('-last_update')[:50]) + pkgs += list(Package.objects.select_related( + 'arch', 'repo').filter(arch=arch).order_by('-last_update')[:50]) pkgs.sort(key=lambda q: q.last_update) updates = [] ctr = 0 while ctr < 15 and len(pkgs) > 0: # not particularly happy with this logic, but it works. p = pkgs.pop() - samepkgs = filter(lambda q: p.is_same_version(q) and p.repo == q.repo, pkgs) + is_same = lambda q: p.is_same_version(q) and p.repo == q.repo + samepkgs = filter(is_same, pkgs) samepkgs.append(p) - samepkgs.sort(key=lambda q: q.arch.name) + samepkgs.sort(key=attrgetter('arch.name')) updates.append(samepkgs) for q in samepkgs: if p != q: pkgs.remove(q) diff --git a/public/views.py b/public/views.py index f2c649f9..be0ff80d 100644 --- a/public/views.py +++ b/public/views.py @@ -1,5 +1,5 @@ from main.models import Arch, Donor, MirrorUrl, News -from main.models import Package, Repo +from main.models import Repo from . import utils from django.contrib.auth.models import User |