wip (feat/game_skill_improvement): add sentry response when db is out of date, healthcheck now is True all of time
@@ -35,12 +35,12 @@ def db_is_updated():
curr_date = datetime.datetime.now()
min_update_time = datetime.timedelta(hours=25)
file_modification_time = datetime.datetime.fromtimestamp(DB_FILE.lstat().st_mtime if DB_FILE.exists() else 0)
- if curr_date - min_update_time > file_modification_time:
- return False, ("db is out of date"
- f", latest update date is {file_modification_time.strftime('%m/%d/%Y, %H:%M:%S')}")
- else:
- return True, ("db is updated"
- f", latest update date is {file_modification_time.strftime('%m/%d/%Y, %H:%M:%S')}")
+ data_is_expired = curr_date - min_update_time > file_modification_time
+ msg = "db is expired" if data_is_expired else "db is updated"
+ msg += f", last modified date of db is {file_modification_time.strftime('%m/%d/%Y, %H:%M:%S')}"
+ if data_is_expired:
+ sentry_sdk.capture_message(msg)
+ return True, msg
health.add_check(db_is_updated)
