mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-02 13:22:11 +03:00
cleanupExpiredLogs() ran on every startup and read retention only from the CALL_LOG_RETENTION_DAYS / APP_LOG_RETENTION_DAYS env vars (default 7d when unset), trimming usage_history before the dashboard-based runAutoCleanup() — which respects the configured retention — ever ran. A dashboard 'Data Retention' of 90d was silently overridden, so the Usage Analysis page only showed 7 days after a restart. Retention precedence is now: explicit env var > dashboard DB setting > 7-day default, applied per table (usage_history->usageHistory, call/proxy/detail->callLogs, mcp_tool_audit->mcpAudit). An explicit env var still wins (operator override) and non-DB deployments still fall back to it. Adds getCallLogRetentionDaysOverride / getAppLogRetentionDaysOverride (null when env unset). TDD: log-retention.test.ts gains a case where the env is unset and the dashboard configures 90d — a 30-day usage_history row must survive (was deleted at the 7d default). RED before, GREEN after; the existing env-explicit cases are unchanged. Co-authored-by: akbardwi <akbardwi@users.noreply.github.com>