diff options
author | Dan McGee <dan@archlinux.org> | 2010-02-04 20:44:46 -0600 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2010-02-05 17:03:35 -0600 |
commit | b2f33457f646c9340059d4ab02b5b7280dbeff9d (patch) | |
tree | c0957a7592656144bb2f31342f455812f52036a3 /public/utils.py | |
parent | 6fe8aec0abdfe284439e9d3adda85da8e5c3825b (diff) |
Make recent updates group multiple architectures
It isn't the most elegant operation in the world, but attempt to only show
one line per package, grouping by architecture if multiple were updated in
the same go. This makes the recent packages view a bit more useful as a
heads up view. Implements FS#17304.
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'public/utils.py')
-rw-r--r-- | public/utils.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/public/utils.py b/public/utils.py new file mode 100644 index 00000000..3a604037 --- /dev/null +++ b/public/utils.py @@ -0,0 +1,19 @@ +from archweb.main.models import Arch, Repo, Package + +def get_recent_updates(): + # This is a bit of magic. We are going to show 15 on the front page, but we + # 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(): + # 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.sort(reverse=True, key=lambda q: q.last_update) + for p in pkgs: + samepkgs = filter(lambda q: p.is_same_version(q), pkgs) + p.allarches = '/'.join(sorted([q.arch.name for q in samepkgs])) + for q in samepkgs: + if p != q: pkgs.remove(q) + return pkgs[:15] + +# vim: set ts=4 sw=4 et: |