status check: also check for recent fetches and refreshes

This commit is contained in:
codl 2021-03-13 11:20:42 +01:00
parent 94d146627e
commit f09c606fe6
1 changed files with 7 additions and 4 deletions

View File

@ -20,10 +20,13 @@ def api_status_check():
return ('Redis bad', 500)
if db.session.execute(db.text("""
SELECT count(*) FROM accounts
WHERE last_delete > now() - '10 minutes'::INTERVAL;
""")).fetchone() < 1:
return ('Deletes stalled', 500)
SELECT 1 FROM accounts
WHERE last_delete > now() - '60 minutes'::INTERVAL
OR last_fetch > now() - '60 minutes'::INTERVAL
OR last_refresh > now() - '60 minutes'::INTERVAL
LIMIT 1;
""")).fetchone() is None:
return ('Celery stalled', 500)
return 'OK'