From 8afa3cc2df4d3a53eec44b1b977b0b50b096617d Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Thu, 26 Feb 2015 18:34:21 -0600 Subject: Add details links to third mirror status table Signed-off-by: Dan McGee --- mirrors/utils.py | 9 +++++---- mirrors/views.py | 2 +- templates/mirrors/error_table.html.jinja | 8 +++++--- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/mirrors/utils.py b/mirrors/utils.py index 930adb8d..533cd452 100644 --- a/mirrors/utils.py +++ b/mirrors/utils.py @@ -159,9 +159,7 @@ def get_mirror_errors(cutoff=DEFAULT_CUTOFF, mirror_id=None, show_all=False): cutoff_time = now() - cutoff errors = MirrorLog.objects.filter( is_success=False, check_time__gte=cutoff_time, - url__mirror__public=True).values( - 'url__url', 'url__country', 'url__protocol__protocol', - 'url__mirror__tier', 'error').annotate( + url__mirror__public=True).values('url__id', 'error').annotate( error_count=Count('error'), last_occurred=Max('check_time') ).order_by('-last_occurred', '-error_count') @@ -172,8 +170,11 @@ def get_mirror_errors(cutoff=DEFAULT_CUTOFF, mirror_id=None, show_all=False): url__mirror__public=True) errors = list(errors) + to_fetch = [err['url__id'] for err in errors] + urls = MirrorUrl.objects.select_related( + 'mirror', 'protocol').in_bulk(to_fetch) for err in errors: - err['country'] = Country(err['url__country'], flag_url='') + err['url'] = urls[err['url__id']] return errors diff --git a/mirrors/views.py b/mirrors/views.py index 65fa0123..9c01bc22 100644 --- a/mirrors/views.py +++ b/mirrors/views.py @@ -274,7 +274,7 @@ def status(request, tier=None): error_logs = get_mirror_errors() if tier is not None: error_logs = [log for log in error_logs - if log['url__mirror__tier'] == tier] + if log['url'].mirror.tier == tier] context = status_info.copy() context.update({ diff --git a/templates/mirrors/error_table.html.jinja b/templates/mirrors/error_table.html.jinja index 52f68135..132aae63 100644 --- a/templates/mirrors/error_table.html.jinja +++ b/templates/mirrors/error_table.html.jinja @@ -7,16 +7,18 @@ Error Message Last Occurred Occurrences (last {{ cutoff|hours }}) + {% for log in error_logs %} - {{ log.url__url }} - {{ log.url__protocol__protocol }} - {{ country_flag(log.country) }}{{ log.country.name }} + {{ log.url.url }} + {{ log.url.protocol.protocol }} + {{ country_flag(log.url.country) }}{{ log.url.country.name }} {{ log.error|linebreaksbr }} {{ log.last_occurred|date('Y-m-d H:i') }} {{ log.error_count }} + details {% endfor %} -- cgit v1.1-4-g5e80