feat: add task to flag stale IPs for reevaluation

This commit is contained in:
Lorenzo Venerandi
2026-02-22 18:41:50 +01:00
parent aa49853949
commit b559fd6a84
2 changed files with 74 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
from database import get_database
from logger import get_app_logger
# ----------------------
# TASK CONFIG
# ----------------------
TASK_CONFIG = {
"name": "flag-stale-ips",
"cron": "0 2 * * *", # Run daily at 2 AM
"enabled": True,
"run_when_loaded": False,
}
def main():
app_logger = get_app_logger()
db = get_database()
try:
count = db.flag_stale_ips_for_reevaluation()
if count > 0:
app_logger.info(
f"[Background Task] flag-stale-ips: Flagged {count} stale IPs for reevaluation"
)
else:
app_logger.debug(
"[Background Task] flag-stale-ips: No stale IPs found to flag"
)
except Exception as e:
app_logger.error(
f"[Background Task] flag-stale-ips: Error flagging stale IPs: {e}"
)