summaryrefslogtreecommitdiffstats
path: root/mirrors
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2012-10-11 03:17:55 +0200
committerDan McGee <dan@archlinux.org>2012-10-11 03:17:55 +0200
commitf0b7e73de61c03a5018ed352605e6329611448d2 (patch)
tree9fc2bfb970062599130cd6d8a73ed13f25231dd6 /mirrors
parentddb7f4825f8bf70142735a5ba2f7729ffe5d27c1 (diff)
downloadarchweb-f0b7e73de61c03a5018ed352605e6329611448d2.tar.gz
archweb-f0b7e73de61c03a5018ed352605e6329611448d2.tar.xz
Make mirror log time query a bit more efficient
We don't need the full mirror log objects; we just need a very small subset of values from them here to do the required math and object building. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'mirrors')
-rw-r--r--mirrors/utils.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/mirrors/utils.py b/mirrors/utils.py
index bf030d3..0a32b76 100644
--- a/mirrors/utils.py
+++ b/mirrors/utils.py
@@ -50,12 +50,14 @@ def get_mirror_statuses(cutoff=DEFAULT_CUTOFF):
# The Django ORM makes it really hard to get actual average delay in the
# above query, so run a seperate query for it and we will process the
# results here.
- times = MirrorLog.objects.filter(is_success=True, last_sync__isnull=False,
+ times = MirrorLog.objects.values_list(
+ 'url_id', 'check_time', 'last_sync').filter(
+ is_success=True, last_sync__isnull=False,
check_time__gte=cutoff_time)
delays = {}
- for log in times:
- delay = log.check_time - log.last_sync
- delays.setdefault(log.url_id, []).append(delay)
+ for url_id, check_time, last_sync in times:
+ delay = check_time - last_sync
+ delays.setdefault(url_id, []).append(delay)
if urls:
last_check = max([u.last_check for u in urls])