summaryrefslogtreecommitdiff
path: root/mirrors
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2014-10-21 09:39:06 -0500
committerDan McGee <dan@archlinux.org>2014-10-21 09:40:14 -0500
commit86fd0b722afb53670ef9a155a3c55d688f275c6d (patch)
treefc613902af22b32eca18eca007d2e04ca11bd1dc /mirrors
parent087b4b00031fed52eeddf05ae36825cb498680f0 (diff)
Reduce complexity of status data URL query
Get rid of all the junk trying to only return URLs that have been checked in the last 24 hours; it just isn't worth it. Instead, do that screening only in the views that need it, namely the HTML status page. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'mirrors')
-rw-r--r--mirrors/utils.py14
-rw-r--r--mirrors/views.py5
2 files changed, 9 insertions, 10 deletions
diff --git a/mirrors/utils.py b/mirrors/utils.py
index 4484fa24..8edceb9b 100644
--- a/mirrors/utils.py
+++ b/mirrors/utils.py
@@ -118,20 +118,16 @@ def annotate_url(url, url_data):
def get_mirror_statuses(cutoff=DEFAULT_CUTOFF, mirror_id=None, show_all=False):
cutoff_time = now() - cutoff
- valid_urls = MirrorUrl.objects.filter(
- logs__check_time__gte=cutoff_time).distinct()
-
+ urls = MirrorUrl.objects.select_related(
+ 'mirror', 'protocol').order_by('mirror__id', 'url')
if mirror_id:
- valid_urls = valid_urls.filter(mirror_id=mirror_id)
+ urls = urls.filter(mirror_id=mirror_id)
if not show_all:
- valid_urls = valid_urls.filter(active=True, mirror__active=True,
+ urls = urls.filter(active=True, mirror__active=True,
mirror__public=True)
- url_data = status_data(cutoff, mirror_id)
- urls = MirrorUrl.objects.select_related('mirror', 'protocol').filter(
- id__in=valid_urls).order_by('mirror__id', 'url')
-
if urls:
+ url_data = status_data(cutoff, mirror_id)
urls = [annotate_url(url, url_data.get(url.id, {})) for url in urls]
last_check = max([u.last_check for u in urls if u.last_check])
num_checks = max([u.check_count for u in urls])
diff --git a/mirrors/views.py b/mirrors/views.py
index 1a9741ed..90787763 100644
--- a/mirrors/views.py
+++ b/mirrors/views.py
@@ -245,7 +245,10 @@ def status(request, tier=None):
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:
+ if url.completion_pct is None:
+ # skip URLs that have never been checked
+ continue
+ elif not url.delay or url.delay > bad_timedelta:
bad_urls.append(url)
else:
good_urls.append(url)