summaryrefslogtreecommitdiff
path: root/devel
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-04-25 18:09:39 -0500
committerDan McGee <dan@archlinux.org>2011-04-25 18:09:39 -0500
commit381e0a787205af530ae11bac1b1a17e567eecc84 (patch)
tree7d1904c757972b3ffd7f2aa101b2d88be3df7987 /devel
parente6717510a0a7976fca1ccd3e5aaf1a16123a1ad4 (diff)
Developer reports
This commit adds four initial developer reports that are hopefully useful to developers and packages in checking up on the state of things. They include: * big : the 100 biggest packages in the repos * old : packages built > 2 years ago * uncompressed-man : self-explanatory * uncompressed-info : self-explanatory There should obviously be some sort of index page to access all of these, so that will be coming soon. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'devel')
-rw-r--r--devel/urls.py9
-rw-r--r--devel/views.py54
2 files changed, 54 insertions, 9 deletions
diff --git a/devel/urls.py b/devel/urls.py
index 41be2b31..9bf50f45 100644
--- a/devel/urls.py
+++ b/devel/urls.py
@@ -1,12 +1,13 @@
from django.conf.urls.defaults import patterns
urlpatterns = patterns('devel.views',
- (r'^$', 'index'),
+ (r'^admin_log/$','admin_log'),
+ (r'^admin_log/(?P<username>.*)/$','admin_log'),
(r'^clock/$', 'clock'),
- (r'^profile/$', 'change_profile'),
+ (r'^$', 'index'),
(r'^newuser/$', 'new_user_form'),
- (r'^admin_log/(?P<username>.*)/$','admin_log'),
- (r'^admin_log/$','admin_log'),
+ (r'^profile/$', 'change_profile'),
+ (r'^reports/(?P<report>.*)/$', 'report'),
)
# vim: set ts=4 sw=4 et:
diff --git a/devel/views.py b/devel/views.py
index b61e605f..01d54e6f 100644
--- a/devel/views.py
+++ b/devel/views.py
@@ -6,19 +6,22 @@ from django.contrib.auth.models import User, Group
from django.contrib.sites.models import Site
from django.core.mail import send_mail
from django.db import transaction
+from django.db.models import Q
+from django.http import Http404
from django.shortcuts import get_object_or_404
from django.template import loader, Context
from django.views.decorators.cache import never_cache
from django.views.generic.simple import direct_to_template
-from main.models import Package, TodolistPkg
+from main.models import Package, PackageFile, TodolistPkg
from main.models import Arch, Repo
from main.models import UserProfile
from packages.models import PackageRelation
from todolists.utils import get_annotated_todolists
from .utils import get_annotated_maintainers
-import datetime
+from datetime import datetime, timedelta
+import operator
import pytz
import random
from string import ascii_letters, digits
@@ -26,7 +29,7 @@ from string import ascii_letters, digits
@login_required
@never_cache
def index(request):
- '''the Developer dashboard'''
+ '''the developer dashboard'''
inner_q = PackageRelation.objects.filter(user=request.user).values('pkgbase')
flagged = Package.objects.select_related('arch', 'repo').filter(
flag_date__isnull=False, pkgbase__in=inner_q).order_by('pkgname')
@@ -70,8 +73,8 @@ def clock(request):
'username').select_related('userprofile')
# now annotate each dev object with their current time
- now = datetime.datetime.now()
- utc_now = datetime.datetime.utcnow().replace(tzinfo=pytz.utc)
+ now = datetime.now()
+ utc_now = datetime.utcnow().replace(tzinfo=pytz.utc)
for dev in devs:
# Work around https://bugs.launchpad.net/pytz/+bug/718673
timezone = str(dev.userprofile.time_zone)
@@ -123,6 +126,47 @@ def change_profile(request):
return direct_to_template(request, 'devel/profile.html',
{'form': form, 'profile_form': profile_form})
+@login_required
+def report(request, report):
+ title = "Developer Report"
+ packages = Package.objects.select_related('arch', 'repo')
+ names = attrs = None
+ if report == "old":
+ title = "Packages last built more than two years ago"
+ cutoff = datetime.now() - timedelta(days=730)
+ packages = packages.filter(build_date__lt=cutoff).order_by('build_date')
+ elif report == "big":
+ title = "100 largest compressed packages"
+ packages = packages.order_by('-compressed_size')[:100]
+ names = [ 'Compressed Size', 'Installed Size' ]
+ attrs = [ 'compressed_size', 'installed_size' ]
+ elif report == "uncompressed-man":
+ title = "Packages with uncompressed manpages"
+ # magic going on here! Checking for all '.1'...'.9' extensions
+ invalid_endings = [Q(filename__endswith='.%d' % n) for n in range(1,10)]
+ invalid_endings.append(Q(filename__endswith='.n'))
+ bad_files = PackageFile.objects.filter(Q(directory__contains='man') & (
+ reduce(operator.or_, invalid_endings))
+ ).values_list('pkg_id', flat=True).distinct()
+ packages = packages.filter(id__in=set(bad_files))
+ elif report == "uncompressed-info":
+ title = "Packages with uncompressed infopages"
+ bad_files = PackageFile.objects.filter(directory__contains='/info',
+ filename__endswith='.info').values_list(
+ 'pkg_id', flat=True).distinct()
+ packages = packages.filter(id__in=set(bad_files))
+ else:
+ raise Http404
+
+ context = {
+ 'title': title,
+ 'packages': packages,
+ 'column_names': names,
+ 'column_attrs': attrs,
+ }
+ return direct_to_template(request, 'devel/packages.html', context)
+
+
class NewUserForm(forms.ModelForm):
username = forms.CharField(max_length=30)
private_email = forms.EmailField()