Filter out things like 404s from the partner pages hit count graph, because they cause the system to return the same problem response.
@@ -34,25 +34,21 @@ class DashboardView(TemplateView):
"""
template_name = 'dashboard.html'
- # As written, this tries to use the partner name as the pk, which won't work.
- # Just returning none for now.
def _get_partner_from_path(self, path):
- # if not path.startswith('/'):
- # path = '/' + path
- # if not path.endswith('/'):
- # path = path + '/'
-
- # try:
- # pk = resolve(path).kwargs['pk']
- # except KeyError:
- # return None
-
- # try:
- # return Partner.even_not_available.get(pk=pk)
- # except Partner.DoesNotExist:
- # return None
+ if not path.startswith('/'):
+ path = '/' + path
+ if not path.endswith('/'):
+ path = path + '/'
+
+ try:
+ pk = resolve(path).kwargs['pk']
+ except KeyError:
return None
+ try:
+ return Partner.even_not_available.get(pk=pk)
+ except Partner.DoesNotExist:
+ return None
def get_context_data(self, **kwargs):
context = super(DashboardView, self).get_context_data(**kwargs)
@@ -65,7 +61,11 @@ class DashboardView(TemplateView):
).order_by('-the_count')[:10]
context['top_pages'] = top_pages
- partner_pages = Request.objects.filter(path__startswith='/partners/'
+ # filter by response code to prevent the report itself from hosing.
+ # 2xx reposnse codes are all valid, so this was a quick and dirty way
+ # to fix the issue. This view probably needs to be rethought.
+ partner_pages = Request.objects).filter(response__startswith='2'
+ ).filter(path__startswith='/partners/'
).values('path'
).annotate(the_count=Count('path')
).order_by('-the_count')
