lazyflat/web/retention.py
Moritz c630b500ef multi-user: users, per-user profiles/filters/notifications, tab UI, apply forensics
* DB: users + user_profiles/filters/notifications/preferences; applications gets
  user_id + forensics_json + profile_snapshot_json; new errors table
  with 14d retention; schema versioning via MIGRATIONS list
* auth: password hashes in DB (argon2); env vars seed first admin; per-user
  sessions; CSRF bound to user id
* apply: personal info/WBS moved out of env into the request body; providers
  take an ApplyContext with Profile + submit_forms; full Playwright recorder
  (step log, console, page errors, network, screenshots, final HTML)
* web: five top-level tabs (Wohnungen/Bewerbungen/Logs/Fehler/Einstellungen);
  settings sub-tabs profil/filter/benachrichtigungen/account/benutzer;
  per-user matching, auto-apply and notifications (UI/Telegram/SMTP); red
  auto-apply switch on Wohnungen tab; forensics detail view for bewerbungen
  and fehler; retention background thread

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-21 10:52:41 +02:00

24 lines
643 B
Python

"""Background thread that periodically prunes old logs / errors / forensics."""
import logging
import threading
import time
import db
from settings import RETENTION_RUN_INTERVAL_SECONDS
logger = logging.getLogger("web.retention")
def _loop():
while True:
try:
db.cleanup_retention()
except Exception:
logger.exception("retention cleanup failed")
time.sleep(RETENTION_RUN_INTERVAL_SECONDS)
def start() -> None:
t = threading.Thread(target=_loop, name="retention", daemon=True)
t.start()
logger.info("retention thread started (interval=%ss)", RETENTION_RUN_INTERVAL_SECONDS)