summaryrefslogtreecommitdiffstats
path: root/mirrors/utils.py
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2014-10-21 10:01:53 -0500
committerDan McGee <dan@archlinux.org>2014-10-21 10:01:53 -0500
commitf53ea0b102d0251a98116aad445d55570c71931c (patch)
tree0b65bd9f509cbab9c01ba89dbe031965bf4447ae /mirrors/utils.py
parent48509bfdbdadb8255f32c56d993f91262516916f (diff)
downloadarchweb-f53ea0b102d0251a98116aad445d55570c71931c.tar.gz
archweb-f53ea0b102d0251a98116aad445d55570c71931c.zip
Move caching of function data back to get_mirror_statuses
We've moved this around a few times, including changing the parameters to ensure they are stable (commit bdfa22500f4). However, the bulk of the work takes place in the mashing up of the data, so cache the full result rather than just the result of a single query. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'mirrors/utils.py')
-rw-r--r--mirrors/utils.py7
1 files changed, 3 insertions, 4 deletions
diff --git a/mirrors/utils.py b/mirrors/utils.py
index fb867dee..5685c9c8 100644
--- a/mirrors/utils.py
+++ b/mirrors/utils.py
@@ -21,9 +21,7 @@ def dictfetchall(cursor):
for row in cursor.fetchall()
]
-@cache_function(178)
-def status_data(cutoff=DEFAULT_CUTOFF, mirror_id=None):
- cutoff_time = now() - cutoff
+def status_data(cutoff_time, mirror_id=None):
if mirror_id is not None:
params = [cutoff_time, mirror_id]
mirror_where = 'AND u.mirror_id = %s'
@@ -115,6 +113,7 @@ def annotate_url(url, url_data):
return url
+@cache_function(178)
def get_mirror_statuses(cutoff=DEFAULT_CUTOFF, mirror_id=None, show_all=False):
cutoff_time = now() - cutoff
@@ -127,7 +126,7 @@ def get_mirror_statuses(cutoff=DEFAULT_CUTOFF, mirror_id=None, show_all=False):
mirror__public=True)
if urls:
- url_data = status_data(cutoff, mirror_id)
+ url_data = status_data(cutoff_time, 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])