diff options
Diffstat (limited to 'packages')
-rw-r--r-- | packages/views.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/packages/views.py b/packages/views.py index 3caf5ec9..ae31f150 100644 --- a/packages/views.py +++ b/packages/views.py @@ -11,7 +11,7 @@ from django.contrib.admin.widgets import AdminDateWidget from django.views.decorators.cache import never_cache from django.views.decorators.vary import vary_on_headers from django.views.generic import list_detail -from django.db.models import Count, Q +from django.db.models import Count, Max, Q from datetime import datetime from operator import itemgetter @@ -88,13 +88,14 @@ def details(request, name='', repo='', arch=''): def get_group_information(): raw_groups = PackageGroup.objects.values_list( 'name', 'pkg__arch__name').order_by('name').annotate( - cnt=Count('pkg')) + cnt=Count('pkg'), last_update=Max('pkg__last_update')) # now for post_processing. we need to seperate things out and add # the count in for 'any' to all of the other architectures. group_mapping = {} for g in raw_groups: arch_groups = group_mapping.setdefault(g[1], {}) - arch_groups[g[0]] = {'name': g[0], 'arch': g[1], 'count': g[2]} + arch_groups[g[0]] = {'name': g[0], 'arch': g[1], + 'count': g[2], 'last_update': g[3]} # we want to promote the count of 'any' packages in groups to the # other architectures, and also add any 'any'-only groups @@ -104,7 +105,10 @@ def get_group_information(): for arch, arch_groups in group_mapping.iteritems(): for g in any_groups.itervalues(): if g['name'] in arch_groups: - arch_groups[g['name']]['count'] += g['count'] + found = arch_groups[g['name']] + found['count'] += g['count'] + if g['last_update'] > found['last_update']: + found['last_update'] = g['last_update'] else: new_g = g.copy() # override the arch to not be 'any' |