def template_context(self): INFO_TABLE = ('today', 'this_week', 'this_month', 'this_year', 'all') INFO_TABLE_QUERIES = [getattr(Request.objects, query, None)() for query in INFO_TABLE] return { 'traffic': modules.table(INFO_TABLE_QUERIES) }
def overview(self, request): days = [date.today() - timedelta(day) for day in range(30)] days_qs = [(day, Request.objects.day(date=day)) for day in days] return render_to_response('admin/request/request/overview.html', { 'title': _('Request overview'), 'traffic_table': modules.table(INFO_TABLE_QUERIES), 'traffic_graph': simplejson.dumps(modules.graph(days_qs)), 'lastest_requests': Request.objects.all()[:5], 'top_paths': set_count(Request.objects.this_month().filter(response__lt=400).values_list('path', flat=True))[:10], 'top_error_paths': set_count(Request.objects.this_month().filter(response__gte=400).values_list('path', flat=True))[:10], 'top_referrers': set_count(Request.objects.this_month().unique_visits().values_list('referer', flat=True))[:10], 'top_browsers': set_count(Request.objects.this_month().only('user_agent').attr_list('browser'))[:5], 'top_search_phrases': set_count(Request.objects.this_month().search().only('referer').attr_list('keywords'))[:10], 'use_hosted_media': settings.REQUEST_USE_HOSTED_MEDIA }, context_instance=RequestContext(request))
def template_context(self): INFO_TABLE = ("today", "this_week", "this_month", "this_year", "all") INFO_TABLE_QUERIES = [getattr(Request.objects, query, None)() for query in INFO_TABLE] return {"traffic": modules.table(INFO_TABLE_QUERIES)}