feat: live последние события на Dashboard; retention, health, runbook

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-05-28 11:29:31 +10:00
parent 9ed0670863
commit 108e1756c4
14 changed files with 625 additions and 249 deletions
+1
View File
@@ -0,0 +1 @@
"""Фоновые задачи SAC (retention и др.)."""
+36
View File
@@ -0,0 +1,36 @@
"""CLI: python -m app.jobs.retention"""
from __future__ import annotations
import logging
import sys
from app.config import get_settings
from app.database import SessionLocal
from app.services.retention import purge_old_data
logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s %(message)s")
logger = logging.getLogger("sac.retention")
def main() -> int:
settings = get_settings()
db = SessionLocal()
try:
stats = purge_old_data(db, settings)
logger.info(
"retention done events_deleted=%s problems_deleted=%s",
stats["events_deleted"],
stats["problems_deleted"],
)
return 0
except Exception:
db.rollback()
logger.exception("retention failed")
return 1
finally:
db.close()
if __name__ == "__main__":
sys.exit(main())