summaryrefslogtreecommitdiff
path: root/public/utils.py
diff options
context:
space:
mode:
authorNicolás Reynolds <fauno@kiwwwi.com.ar>2011-03-18 16:11:31 -0300
committerNicolás Reynolds <fauno@kiwwwi.com.ar>2011-03-18 16:11:31 -0300
commit37075e5f3423a69fec03faf31ce2133c55374dfc (patch)
tree7403d5eefd5f20ab2a496dbbb9d9841b06e2e385 /public/utils.py
parent30b2a1954d5bf63c78fe654a0c0bb98508e2f3e2 (diff)
parentaca7700dd7519d45e677e18b1a0199f3712ce140 (diff)
Merge branch 'master' of git://projects.archlinux.org/archweb
Conflicts: templates/packages/details.html templates/packages/files.html
Diffstat (limited to 'public/utils.py')
-rw-r--r--public/utils.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/public/utils.py b/public/utils.py
index 81f589f7..8ce2af45 100644
--- a/public/utils.py
+++ b/public/utils.py
@@ -4,19 +4,20 @@ from main.models import Arch, Package
from main.utils import cache_function
@cache_function(300)
-def get_recent_updates():
+def get_recent_updates(number=15):
# 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 = []
+ # grab a few extra so we can hopefully catch everything we need
+ fetch = number * 4
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=arch).order_by('-last_update')[:50])
+ 'arch', 'repo').filter(arch=arch).order_by('-last_update')[:fetch])
pkgs.sort(key=attrgetter('last_update'))
updates = []
ctr = 0
- while ctr < 15 and len(pkgs) > 0:
+ while ctr < number and len(pkgs) > 0:
# not particularly happy with this logic, but it works.
p = pkgs.pop()
is_same = lambda q: p.is_same_version(q) and p.repo == q.repo