2021-01-22 19:41:11 +02:00
|
|
|
import Setting from '../models/Setting';
|
|
|
|
import ItemChange from '../models/ItemChange';
|
2019-01-14 21:11:54 +02:00
|
|
|
|
2021-08-30 19:53:24 +02:00
|
|
|
const dayMs = 86400000;
|
|
|
|
|
2021-01-22 19:41:11 +02:00
|
|
|
export default class ItemChangeUtils {
|
2021-08-30 19:53:24 +02:00
|
|
|
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 21:11:54 +02:00
|
|
|
|
|
|
|
const lowestChangeId = Math.min(...lastProcessedChangeIds);
|
2021-08-30 19:53:24 +02:00
|
|
|
await ItemChange.deleteOldChanges(lowestChangeId, itemMinTtl);
|
2019-01-14 21:11:54 +02:00
|
|
|
}
|
|
|
|
}
|