summaryrefslogtreecommitdiff
path: root/mirrors
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2010-09-24 13:26:08 -0500
committerDan McGee <dan@archlinux.org>2010-09-24 13:26:08 -0500
commite82e953aa297f1e54d0aff9b2097aaab6d58d0ba (patch)
tree88ee0e1badd0b9b512d2902b8f62a8844160448f /mirrors
parent00e9dce4db7df23f2fcf43ea8c46ee0d8ca5e262 (diff)
Mirror status query refinements
Only show errors for active and public mirrors, and collapse two filter calls into just one for our normal status query. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'mirrors')
-rw-r--r--mirrors/utils.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/mirrors/utils.py b/mirrors/utils.py
index 5c8bff3b..69909dcf 100644
--- a/mirrors/utils.py
+++ b/mirrors/utils.py
@@ -11,10 +11,9 @@ def get_mirror_statuses():
cutoff_time = datetime.datetime.utcnow() - datetime.timedelta(hours=24)
protocols = MirrorProtocol.objects.exclude(protocol__iexact='rsync')
# I swear, this actually has decent performance...
- urls = MirrorUrl.objects.select_related(
- 'mirror', 'protocol').filter(
+ urls = MirrorUrl.objects.select_related('mirror', 'protocol').filter(
mirror__active=True, mirror__public=True,
- protocol__in=protocols).filter(
+ protocol__in=protocols,
logs__check_time__gte=cutoff_time).annotate(
check_count=Count('logs'), last_sync=Max('logs__last_sync'),
last_check=Max('logs__check_time'),
@@ -48,7 +47,8 @@ def get_mirror_statuses():
def get_mirror_errors():
cutoff_time = datetime.datetime.utcnow() - datetime.timedelta(hours=24)
errors = MirrorLog.objects.filter(
- is_success=False, check_time__gte=cutoff_time).values(
+ is_success=False, check_time__gte=cutoff_time,
+ url__mirror__active=True, url__mirror__public=True).values(
'url__url', 'url__protocol__protocol', 'url__mirror__country',
'error').annotate(
error_count=Count('error'), last_occurred=Max('check_time')