summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2013-12-14 17:10:52 -0600
committerDan McGee <dan@archlinux.org>2013-12-14 17:10:52 -0600
commitbdfa22500f47fcfa0f40de14424c25792995c9e9 (patch)
tree04682d259ea1499b6b2dda6b9773da0f0fb84741
parent0b0e2b9d2aabd1c34f742e6525ee075751600e37 (diff)
Use stable parameters for cacheable function
It doesn't do much good to mark a function as cacheable if we call it every single time with different arguments due to using the current date and time. Fix it by passing the offset in instead. Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r--mirrors/utils.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/mirrors/utils.py b/mirrors/utils.py
index 9f40bca6..0dd26ae0 100644
--- a/mirrors/utils.py
+++ b/mirrors/utils.py
@@ -22,7 +22,8 @@ def dictfetchall(cursor):
]
@cache_function(178)
-def status_data(cutoff_time, mirror_id=None):
+def status_data(cutoff=DEFAULT_CUTOFF, mirror_id=None):
+ cutoff_time = now() - cutoff
if mirror_id is not None:
params = [cutoff_time, mirror_id]
mirror_where = 'AND u.mirror_id = %s'
@@ -125,7 +126,7 @@ def get_mirror_statuses(cutoff=DEFAULT_CUTOFF, mirror_id=None, show_all=False):
valid_urls = valid_urls.filter(active=True, mirror__active=True,
mirror__public=True)
- url_data = status_data(cutoff_time, mirror_id)
+ url_data = status_data(cutoff, mirror_id)
urls = MirrorUrl.objects.select_related('mirror', 'protocol').filter(
id__in=valid_urls).order_by('mirror__id', 'url')