From f3e2caeaa7380736fc7a919241c21fc8b3dacb6b Mon Sep 17 00:00:00 2001 From: Bill Nottingham Date: Thu, 6 Feb 2020 21:41:41 -0500 Subject: [PATCH] Bypass memcached to get last gather time to avoid reading cached values. --- awx/main/tasks.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/awx/main/tasks.py b/awx/main/tasks.py index 08f550c072..54e65b3f50 100644 --- a/awx/main/tasks.py +++ b/awx/main/tasks.py @@ -338,9 +338,15 @@ def send_notifications(notification_list, job_id=None): @task() def gather_analytics(): + from awx.conf.models import Setting + from rest_framework.fields import DateTimeField if not settings.INSIGHTS_TRACKING_STATE: return - last_time = settings.AUTOMATION_ANALYTICS_LAST_GATHER + last_gather = Setting.objects.filter(key='AUTOMATION_ANALYTICS_LAST_GATHER').first() + if last_gather: + last_time = DateTimeField().to_internal_value(last_gather.value) + else: + last_time = None gather_time = now() if not last_time or ((gather_time - last_time).total_seconds() > settings.AUTOMATION_ANALYTICS_GATHER_INTERVAL): with advisory_lock('gather_analytics_lock', wait=False) as acquired: