summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2012-05-13 20:35:50 -0500
committerDan McGee <dan@archlinux.org>2012-05-13 20:37:27 -0500
commitae1c526ffbe908322f0dd8d8805360b81ab22b0f (patch)
tree8dc77cae76ceaa7838d2d54c3e5a6b1dd50a74f6
parent2f7d770b261b3428bcff366ba6ff4fa631dd980a (diff)
Add ability to restrict status report to single tierrelease_2012-05-13
This should make it easier to catch errors in our Tier 1 mirrors. Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r--mirrors/urls.py1
-rw-r--r--mirrors/utils.py2
-rw-r--r--mirrors/views.py19
-rw-r--r--templates/mirrors/status.html4
4 files changed, 20 insertions, 6 deletions
diff --git a/mirrors/urls.py b/mirrors/urls.py
index f002e9d6..bb4eb969 100644
--- a/mirrors/urls.py
+++ b/mirrors/urls.py
@@ -4,6 +4,7 @@ urlpatterns = patterns('mirrors.views',
(r'^$', 'mirrors', {}, 'mirror-list'),
(r'^status/$', 'status', {}, 'mirror-status'),
(r'^status/json/$', 'status_json', {}, 'mirror-status-json'),
+ (r'^status/tier/(?P<tier>\d+)/$', 'status', {}, 'mirror-status-tier'),
(r'^(?P<name>[\.\-\w]+)/$', 'mirror_details'),
)
diff --git a/mirrors/utils.py b/mirrors/utils.py
index 54de567e..2014411d 100644
--- a/mirrors/utils.py
+++ b/mirrors/utils.py
@@ -88,7 +88,7 @@ def get_mirror_errors(cutoff=default_cutoff):
is_success=False, check_time__gte=cutoff_time,
url__mirror__active=True, url__mirror__public=True).values(
'url__url', 'url__country', 'url__protocol__protocol',
- 'url__mirror__country', 'error').annotate(
+ 'url__mirror__country', 'url__mirror__tier', 'error').annotate(
error_count=Count('error'), last_occurred=Max('check_time')
).order_by('-last_occurred', '-error_count')
errors = list(errors)
diff --git a/mirrors/views.py b/mirrors/views.py
index b0be6238..8f092be7 100644
--- a/mirrors/views.py
+++ b/mirrors/views.py
@@ -13,7 +13,7 @@ from django.views.decorators.csrf import csrf_exempt
from django.views.generic.simple import direct_to_template
from django_countries.countries import COUNTRIES
-from .models import Mirror, MirrorUrl, MirrorProtocol
+from .models import Mirror, MirrorUrl, MirrorProtocol, TIER_CHOICES
from .utils import get_mirror_statuses, get_mirror_errors
COUNTRY_LOOKUP = dict(COUNTRIES)
@@ -184,7 +184,11 @@ def mirror_details(request, name):
{'mirror': mirror, 'urls': all_urls})
-def status(request):
+def status(request, tier=None):
+ if tier is not None:
+ tier = int(tier)
+ if tier not in [t[0] for t in TIER_CHOICES]:
+ raise Http404
bad_timedelta = timedelta(days=3)
status_info = get_mirror_statuses()
@@ -192,17 +196,26 @@ def status(request):
good_urls = []
bad_urls = []
for url in urls:
+ # screen by tier if we were asked to
+ if tier is not None and url.mirror.tier != tier:
+ continue
# split them into good and bad lists based on delay
if not url.delay or url.delay > bad_timedelta:
bad_urls.append(url)
else:
good_urls.append(url)
+ error_logs = get_mirror_errors()
+ if tier is not None:
+ error_logs = [log for log in error_logs
+ if log['url__mirror__tier'] == tier]
+
context = status_info.copy()
context.update({
'good_urls': sorted(good_urls, key=attrgetter('score')),
'bad_urls': sorted(bad_urls, key=lambda u: u.delay or timedelta.max),
- 'error_logs': get_mirror_errors(),
+ 'error_logs': error_logs,
+ 'tier': tier,
})
return direct_to_template(request, 'mirrors/status.html', context)
diff --git a/templates/mirrors/status.html b/templates/mirrors/status.html
index 2c350f56..472e9501 100644
--- a/templates/mirrors/status.html
+++ b/templates/mirrors/status.html
@@ -2,11 +2,11 @@
{% load static from staticfiles %}
{% load mirror_status %}
-{% block title %}Arch Linux - Mirror Status{% endblock %}
+{% block title %}Arch Linux - Mirror Status{% if tier != None %} - Tier {{ tier }}{% endif %}{% endblock %}
{% block content %}
<div id="mirrorstatus" class="box">
- <h2>Mirror Status</h2>
+ <h2>Mirror Status{% if tier != None %} - Tier {{ tier }}{% endif %}</h2>
<p>This page reports the status of all known, public, and active Arch Linux
mirrors. All data on this page reflects the status of the mirrors within
the <em>last {{ cutoff|hours }}</em>. All listed times are UTC. The check script runs