Self-hosted dashboard and admin auth (#4837)

Co-authored-by: kartik-mem0 <kartik.labhshetwar@mem0.ai>
This commit is contained in:
Gabriel Stein
2026-04-23 19:06:36 +05:30
committed by GitHub
co-authored by kartik-mem0
parent 15feaa8ac4
commit db8ac61713
252 changed files with 20275 additions and 331 deletions
+36
View File
@@ -0,0 +1,36 @@
"""Delete request_logs rows older than REQUEST_LOG_RETENTION_DAYS (default 30).
Run inside the `mem0` container, or wire into cron / a systemd timer on the host.
"""
import os
import sys
from datetime import datetime, timedelta, timezone
from sqlalchemy import delete
from db import SessionLocal
from models import RequestLog
def main() -> int:
raw = os.environ.get("REQUEST_LOG_RETENTION_DAYS", "").strip() or "30"
try:
retention_days = int(raw)
except ValueError:
sys.stderr.write("REQUEST_LOG_RETENTION_DAYS must be an integer.\n")
return 1
if retention_days < 1:
sys.stderr.write("REQUEST_LOG_RETENTION_DAYS must be >= 1.\n")
return 1
cutoff = datetime.now(timezone.utc) - timedelta(days=retention_days)
with SessionLocal() as session:
result = session.execute(delete(RequestLog).where(RequestLog.created_at < cutoff))
session.commit()
sys.stdout.write(f"Deleted {result.rowcount or 0} request_logs rows older than {cutoff.isoformat()}.\n")
return 0
if __name__ == "__main__":
raise SystemExit(main())