[codex] fix runtime settings restart hydration (#392)

* fix runtime settings restart hydration

* fix review followups for settings hydration

* dedupe log cleanup day normalization
This commit is contained in:
Cita
2026-04-02 17:27:25 +08:00
committed by GitHub
parent 1407f754b1
commit 082891a217
8 changed files with 365 additions and 279 deletions
+2 -1
View File
@@ -7,7 +7,8 @@ import { checkinAll } from './checkinService.js';
import * as routeRefreshWorkflow from './routeRefreshWorkflow.js';
import { sendNotification } from './notifyService.js';
import { buildDailySummaryNotification, collectDailySummaryMetrics } from './dailySummaryService.js';
import { cleanupConfiguredLogs, normalizeLogCleanupRetentionDays } from './logCleanupService.js';
import { cleanupConfiguredLogs } from './logCleanupService.js';
import { normalizeLogCleanupRetentionDays } from '../shared/logCleanupRetentionDays.js';
export type CheckinScheduleMode = 'cron' | 'interval';
+1 -10
View File
@@ -2,6 +2,7 @@ import { lt } from 'drizzle-orm';
import { config } from '../config.js';
import { db, schema } from '../db/index.js';
import { formatUtcSqlDateTime } from './localTimeService.js';
import { normalizeLogCleanupRetentionDays } from '../shared/logCleanupRetentionDays.js';
const DAY_MS = 24 * 60 * 60 * 1000;
@@ -23,16 +24,6 @@ export type LogCleanupResult = {
totalDeleted: number;
};
export function normalizeLogCleanupRetentionDays(value: unknown, fallback = 30): number {
const parsed = Number(value);
if (Number.isFinite(parsed) && parsed >= 1) return Math.trunc(parsed);
const fallbackParsed = Number(fallback);
if (Number.isFinite(fallbackParsed) && fallbackParsed >= 1) return Math.trunc(fallbackParsed);
return 30;
}
export function getLogCleanupCutoffUtc(retentionDays: number, nowMs = Date.now()): string | null {
const normalizedDays = normalizeLogCleanupRetentionDays(retentionDays);
return formatUtcSqlDateTime(new Date(nowMs - normalizedDays * DAY_MS));