import type { Job } from 'bullmq'; import { eventBuffer, groupBuffer, profileBackfillBuffer, profileBuffer, replayBuffer, sessionBuffer } from '@openpanel/db'; import type { CronQueuePayload } from '@openpanel/queue'; import { jobdeleteProjects } from './cron.delete-projects'; import { gscSyncAllJob } from './gsc'; import { onboardingJob } from './cron.onboarding'; import { ping } from './cron.ping'; import { salt } from './cron.salt'; import { insightsDailyJob } from './insights'; export async function cronJob(job: Job) { switch (job.data.type) { case 'salt': { return await salt(); } case 'flushEvents': { return await eventBuffer.tryFlush(); } case 'flushProfiles': { return await profileBuffer.tryFlush(); } case 'flushSessions': { return await sessionBuffer.tryFlush(); } case 'flushProfileBackfill': { return await profileBackfillBuffer.tryFlush(); } case 'flushReplay': { return await replayBuffer.tryFlush(); } case 'flushGroups': { return await groupBuffer.tryFlush(); } case 'ping': { return await ping(); } case 'deleteProjects': { return await jobdeleteProjects(job); } case 'insightsDaily': { return await insightsDailyJob(job); } case 'onboarding': { return await onboardingJob(job); } case 'gscSync': { return await gscSyncAllJob(); } } }