#!/usr/bin/env python3
"""
Automatische Medien-Retention (Papierkorb Stufe 1→2, Purge wenn fällig).

Lauf z. B. täglich per Cron:
  cd /path/to/backend && python scripts/media_retention_job.py

Umgebung wie Backend (DB_*), optional:
  MEDIA_TRASH_SOFT_TO_HIDDEN_DAYS (Default 30)
  MEDIA_TRASH_HIDDEN_TO_PURGE_DAYS (Default 90)
"""
from __future__ import annotations

import os
import sys

# Repo-Root: backend/scripts -> parents[1] == backend
_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
if _ROOT not in sys.path:
    sys.path.insert(0, _ROOT)

from db import get_db, get_cursor  # noqa: E402
from media_lifecycle import run_retention_pass  # noqa: E402


def main() -> int:
    with get_db() as conn:
        cur = get_cursor(conn)
        summary = run_retention_pass(cur, conn)
    print(summary)
    return 0


if __name__ == "__main__":
    raise SystemExit(main())
