summaryrefslogtreecommitdiffstats
path: root/public/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'public/utils.py')
-rw-r--r--public/utils.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/public/utils.py b/public/utils.py
index c92cb26..2801c93 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)