From 979b7333aefc3712164e03b2c4cc11eb071e29db Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Oct 02 2019 01:35:05 +0000 Subject: Ditch caching of current_releases as fedfind does it for us fedfind caches collections data anyway, so this is effectively duplicating that. (Also the one-day expiry wasn't working because fedfind's collections cache had no expiry; I've moved the one-day expiry logic to the fedfind cache in 4.2.8). Signed-off-by: Adam Williamson --- diff --git a/fedora_nightlies.py b/fedora_nightlies.py index f62c1e2..4d0db86 100755 --- a/fedora_nightlies.py +++ b/fedora_nightlies.py @@ -40,9 +40,6 @@ from openqa_client import const as oqc from urllib.parse import urlencode from urllib.request import Request -# global for caching purposes -CURRENT_RELEASES = [] - # HTML template HTML_TEMPLATE = """ @@ -83,31 +80,16 @@ logger = logging.getLogger(__name__) def current_releases(): """Figure out what releases we care about: for now, that's Rawhide - plus Branched if there is one. Cached by global var, expires after - one day (so I don't have to reset the fedmsg consumer every time - we cut a release or branch...) + plus Branched if there is one. Note: we don't cache this any more + as fedfind does it for us (it caches the collections data it uses + to figure this out, with a one day expiry). """ - global CURRENT_RELEASES - if CURRENT_RELEASES: - # check if we should expire the cache. first item in CURRENT_RELEASES - # is the datetime it was last updated - delta = datetime.datetime.utcnow() - CURRENT_RELEASES[0] - # this means "if it was more than a day ago" - if delta > datetime.timedelta(1): - CURRENT_RELEASES = [] - - if not CURRENT_RELEASES: - # figure out if we have a Branched right now. maybe I should make - # fedfind do this better. - curr = fedfind.helpers.get_current_release(branched=False) - branched = fedfind.helpers.get_current_release(branched=True) - if branched > curr: - CURRENT_RELEASES = [datetime.datetime.utcnow(), [str(branched), 'Rawhide']] - else: - CURRENT_RELEASES = [datetime.datetime.utcnow(), ['Rawhide']] - - # only return the actual list, not the timestamp... - return CURRENT_RELEASES[1] + curr = fedfind.helpers.get_current_release(branched=False) + branched = fedfind.helpers.get_current_release(branched=True) + if branched > curr: + return [str(branched), 'Rawhide'] + else: + return ['Rawhide'] def recursive_dict(): """It's defaultdicts all the way down, Jim. Per