mirror of
https://github.com/outline/outline.git
synced 2026-06-13 11:25:03 +03:00
5c938b0d1a
Replace free-form retention days with a fixed set of presets (0, 7, 14, 30, 90, 180, 365) where 0 means infinite/never delete. This bounds the number of cron sub-tasks and simplifies the system by removing findUniquePreferenceValues in favor of iterating over known presets directly. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
49 lines
1.3 KiB
TypeScript
49 lines
1.3 KiB
TypeScript
import Logger from "@server/logging/Logger";
|
|
import { RetentionPeriodPresets } from "@shared/constants";
|
|
import { Minute } from "@shared/utils/time";
|
|
import { TaskPriority } from "./base/BaseTask";
|
|
import { CronTask, TaskInterval } from "./base/CronTask";
|
|
import type { Props } from "./base/CronTask";
|
|
import CleanupPermanentlyDeletedDocumentsByRetentionTask from "./CleanupPermanentlyDeletedDocumentsByRetentionTask";
|
|
|
|
export default class CleanupPermanentlyDeletedDocumentsTask extends CronTask {
|
|
/**
|
|
* Schedules a worker task for each retention period preset.
|
|
*
|
|
* @param props Properties to be used by the task.
|
|
*/
|
|
public async perform(props: Props) {
|
|
const task = new CleanupPermanentlyDeletedDocumentsByRetentionTask();
|
|
|
|
for (const days of RetentionPeriodPresets) {
|
|
if (days === 0) {
|
|
continue;
|
|
}
|
|
await task.schedule({
|
|
limit: props.limit,
|
|
retentionDays: days,
|
|
partition: props.partition,
|
|
});
|
|
}
|
|
|
|
Logger.debug(
|
|
"task",
|
|
`Scheduled ${RetentionPeriodPresets.length - 1} tranches for document cleanup`
|
|
);
|
|
}
|
|
|
|
public get options() {
|
|
return {
|
|
attempts: 1,
|
|
priority: TaskPriority.Background,
|
|
};
|
|
}
|
|
|
|
public get cron() {
|
|
return {
|
|
interval: TaskInterval.Hour,
|
|
partitionWindow: 15 * Minute.ms,
|
|
};
|
|
}
|
|
}
|