summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2015-02-26 18:34:21 -0600
committerDan McGee <dan@archlinux.org>2015-02-26 18:34:21 -0600
commit8afa3cc2df4d3a53eec44b1b977b0b50b096617d (patch)
tree8a06deb5ac16a906fa8dbff1e87727534ea58aac
parentf3214b4b03cc7cc8c4317aae8c8f3353c3f01049 (diff)
Add details links to third mirror status table
Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r--mirrors/utils.py9
-rw-r--r--mirrors/views.py2
-rw-r--r--templates/mirrors/error_table.html.jinja8
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 @@
<th>Error Message</th>
<th>Last Occurred</th>
<th>Occurrences (last {{ cutoff|hours }})</th>
+ <th></th>
</tr>
</thead>
<tbody>
{% for log in error_logs %}<tr class="{{ loop.cycle('odd', 'even') }}">
- <td>{{ log.url__url }}</td>
- <td>{{ log.url__protocol__protocol }}</td>
- <td class="country">{{ country_flag(log.country) }}{{ log.country.name }}</td>
+ <td>{{ log.url.url }}</td>
+ <td>{{ log.url.protocol.protocol }}</td>
+ <td class="country">{{ country_flag(log.url.country) }}{{ log.url.country.name }}</td>
<td class="wrap">{{ log.error|linebreaksbr }}</td>
<td>{{ log.last_occurred|date('Y-m-d H:i') }}</td>
<td>{{ log.error_count }}</td>
+ <td><a href="{{ log.url.get_absolute_url() }}">details</a></td>
</tr>{% endfor %}
</tbody>
</table>