[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:
@@ -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';
|
||||
|
||||
|
||||
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user