Logs grew forever. A daily prune-logs cron now deletes entries older than the app setting logs_keep_days (Settings > General, super admin; default AppData.LogsKeepDays, 90), with an index on logs.created_at. Co-Authored-By: Claude Opus 5.5 <[email protected]>
31 lines
982 B
TypeScript
31 lines
982 B
TypeScript
import { AppData } from "@/src/data/app-data";
|
|
import { LogsKeepDaysSettingKey } from "@/src/dict/log-categories";
|
|
import type { LogRetentionOverview } from "@/src/types";
|
|
import readStepLimit from "@/src/utils/read-step-limit";
|
|
import grabAppSetting from "./grab-app-setting";
|
|
|
|
/**
|
|
* How many days logs are kept: the install's own number (`logs_keep_days`,
|
|
* Settings > General), else `AppData.LogsKeepDays`.
|
|
*/
|
|
export async function grabLogsKeepDays() {
|
|
return readStepLimit({
|
|
saved: await grabAppSetting({ key: LogsKeepDaysSettingKey }),
|
|
fallback: AppData.LogsKeepDays,
|
|
max: AppData.LogsKeepDaysMax,
|
|
});
|
|
}
|
|
|
|
/**
|
|
* The number with its default and ceiling, for the settings page.
|
|
*/
|
|
export default async function grabLogRetentionOverview() {
|
|
const overview: LogRetentionOverview = {
|
|
keep_days: await grabLogsKeepDays(),
|
|
default_days: AppData.LogsKeepDays,
|
|
max: AppData.LogsKeepDaysMax,
|
|
};
|
|
|
|
return overview;
|
|
}
|