Handling missing values

This commit is contained in:
Samuel Clay 2021-01-18 17:45:35 -05:00
parent c9c891e44a
commit 238aa3916a

View file

@ -20,6 +20,7 @@ def main():
failed = False
feeds_fetched = 0
FETCHES_DROP_AMOUNT = 0
redis_task_fetches = 0
monitor_key = "Monitor:task_fetches"
r = redis.Redis(connection_pool=settings.REDIS_ANALYTICS_POOL)
@ -34,9 +35,6 @@ def main():
failed = True
if failed:
r.set(monitor_key, feeds_fetched)
r.expire(monitor_key, 60*60*3) # 3 hours
requests.post(
"https://api.mailgun.net/v2/%s/messages" % settings.MAILGUN_SERVER_NAME,
auth=("api", settings.MAILGUN_ACCESS_KEY),
@ -44,6 +42,10 @@ def main():
"to": [admin_email],
"subject": "%s feeds fetched falling: %s" % (hostname, feeds_fetched),
"text": "Feed fetches are falling: %s" % (feeds_fetched)})
r.set(monitor_key, feeds_fetched)
r.expire(monitor_key, 60*60*3) # 3 hours
print(" ---> Feeds fetched falling! %s" % (feeds_fetched))
else:
print(" ---> Feeds fetched OK: %s" % (feeds_fetched))