summaryrefslogtreecommitdiffstats
path: root/mirrors/views.py
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2012-04-25 14:49:26 +0200
committerDan McGee <dan@archlinux.org>2012-04-25 14:49:26 +0200
commit4dcfaddff526dca2828571326aa7263a3272fcdf (patch)
treeb06a4115e1bca1e1c86ff5218775307a86827a39 /mirrors/views.py
parent021e7717e0dcdb5a18271b60446e2aa5edec5833 (diff)
downloadarchweb-4dcfaddff526dca2828571326aa7263a3272fcdf.tar.gz
archweb-4dcfaddff526dca2828571326aa7263a3272fcdf.tar.xz
Ensure sorted order of mirrors in status page matches with JS
We had one sorting order in the backend, and another once the JS sorting routine kicked in. Match them so we aren't doing more on the client-side on initial display than we have to. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'mirrors/views.py')
-rw-r--r--mirrors/views.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/mirrors/views.py b/mirrors/views.py
index 6c08f71..c52656f 100644
--- a/mirrors/views.py
+++ b/mirrors/views.py
@@ -1,4 +1,4 @@
-import datetime
+from datetime import timedelta
from operator import attrgetter, itemgetter
from django import forms
@@ -152,7 +152,7 @@ def mirror_details(request, name):
def status(request):
- bad_timedelta = datetime.timedelta(days=3)
+ bad_timedelta = timedelta(days=3)
status_info = get_mirror_statuses()
urls = status_info['urls']
@@ -167,8 +167,8 @@ def status(request):
context = status_info.copy()
context.update({
- 'good_urls': good_urls,
- 'bad_urls': bad_urls,
+ '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(),
})
return direct_to_template(request, 'mirrors/status.html', context)
@@ -181,7 +181,7 @@ class MirrorStatusJSONEncoder(DjangoJSONEncoder):
'delay', 'duration_avg', 'duration_stddev', 'score']
def default(self, obj):
- if isinstance(obj, datetime.timedelta):
+ if isinstance(obj, timedelta):
# always returned as integer seconds
return obj.days * 24 * 3600 + obj.seconds
if hasattr(obj, '__iter__'):