2023-09-05 00:45:33 +00:00
|
|
|
import * as eventsDB from '@/db/events.ts';
|
|
|
|
import { cron } from '@/deps.ts';
|
|
|
|
import { Time } from '@/utils/time.ts';
|
|
|
|
|
|
|
|
/** Clean up old remote events. */
|
|
|
|
async function cleanupEvents() {
|
|
|
|
console.log('Cleaning up old remote events...');
|
|
|
|
|
|
|
|
const [result] = await eventsDB.deleteFilters([{
|
|
|
|
until: Math.floor((Date.now() - Time.days(7)) / 1000),
|
|
|
|
local: false,
|
|
|
|
}]);
|
|
|
|
|
2023-09-06 02:52:16 +00:00
|
|
|
console.log(`Cleaned up ${result?.numDeletedRows ?? 0} old remote events.`);
|
2023-09-05 00:45:33 +00:00
|
|
|
}
|
|
|
|
|
2023-09-06 02:52:16 +00:00
|
|
|
await cleanupEvents();
|
|
|
|
|
2023-09-05 22:48:50 +00:00
|
|
|
cron.every15Minute(cleanupEvents);
|