Skip to content

Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors

914 B
Raw Blame
import { getPersistedCallLogRetentionDays } from "../db/databaseSettings";
import { getCallLogRetentionDays, getCallLogRetentionDaysOverride } from "../logEnv";

/**
 * Resolves the request log retention in days: explicit variable override wins,
 * then the dashboard-persisted retention, then the variable-or-7-day fallback.
 * Same precedence as the startup cleanup (src/lib/compliance/index.ts:494-506);
 * unlike the startup path, the dashboard level only honors persisted keys (a
 * merged default never applies). Settings errors fall back to the variable
 * (e.g. very early startup with no settings table yet).
 */
export function resolveCallLogRetentionDays(): number {
  const override = getCallLogRetentionDaysOverride();
  if (override !== null) return override;
  try {
    return getPersistedCallLogRetentionDays() ?? getCallLogRetentionDays();
  } catch {
    return getCallLogRetentionDays();
  }
}