2021-01-22 17:41:11 +00:00
|
|
|
import Setting from '../models/Setting';
|
|
|
|
import ItemChange from '../models/ItemChange';
|
2019-01-14 19:11:54 +00:00
|
|
|
|
2021-08-30 18:53:24 +01:00
|
|
|
const dayMs = 86400000;
|
|
|
|
|
2021-01-22 17:41:11 +00:00
|
|
|
export default class ItemChangeUtils {
|
2023-03-06 14:22:01 +00:00
|
|
|
public static async deleteProcessedChanges(itemMinTtl: number = dayMs * 90) {
|
2021-05-13 18:57:37 +02:00
|
|
|
const lastProcessedChangeIds = [
|
|
|
|
Setting.value('resourceService.lastProcessedChangeId'),
|
|
|
|
Setting.value('searchEngine.lastProcessedChangeId'),
|
|
|
|
Setting.value('revisionService.lastProcessedChangeId'),
|
|
|
|
];
|
2019-01-14 19:11:54 +00:00
|
|
|
|
|
|
|
const lowestChangeId = Math.min(...lastProcessedChangeIds);
|
2021-08-30 18:53:24 +01:00
|
|
|
await ItemChange.deleteOldChanges(lowestChangeId, itemMinTtl);
|
2019-01-14 19:11:54 +00:00
|
|
|
}
|
|
|
|
}
|