ditto/src/cron.ts

20 lines
516 B
TypeScript
Raw Normal View History

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-06 02:52:16 +00:00
await cleanupEvents();
cron.every15Minute(cleanupEvents);