summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2010-08-28 00:24:08 +0200
committerDan McGee <dan@archlinux.org>2010-08-28 00:24:08 +0200
commitd21de73592062bce687e78e2dc4d0f415f42b3cf (patch)
tree0925c12104bfe958f13b8d201f418d1d62c90eec
parentddc4b974fe44832c696724d512fd9b935f5085df (diff)
downloadarchweb-d21de73592062bce687e78e2dc4d0f415f42b3cf.tar.gz
archweb-d21de73592062bce687e78e2dc4d0f415f42b3cf.tar.xz
Add last updated column to package groups view
Just another annotation to the queryset to get this data, and a little more manipulation in the group data function. This will help when adding a sitemap in a subsequent commit. Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r--packages/views.py12
-rw-r--r--templates/packages/groups.html2
2 files changed, 10 insertions, 4 deletions
diff --git a/packages/views.py b/packages/views.py
index 3caf5ec..ae31f15 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'
diff --git a/templates/packages/groups.html b/templates/packages/groups.html
index 4bf12ac..bb475b1 100644
--- a/templates/packages/groups.html
+++ b/templates/packages/groups.html
@@ -11,6 +11,7 @@
<th>Arch</th>
<th>Group Name</th>
<th>Package Count</th>
+ <th>Last Updated</th>
</tr>
</thead>
<tbody>
@@ -20,6 +21,7 @@
<td><a href="/groups/{{ grp.arch }}/{{ grp.name }}/"
title="Group details for {{ grp.name }}">{{ grp.name }}</a></td>
<td>{{ grp.count }} Packages</td>
+ <td>{{ grp.last_update|date:"Y-m-d" }}</td>
</tr>
{% endfor %}
</tbody>