Files
stats/apps/worker/src/jobs/cron.ts
Carl-Gerhard Lindesvärd 11e9ecac1a feat: group analytics
* wip

* wip

* wip

* wip

* wip

* add buffer

* wip

* wip

* fixes

* fix

* wip

* group validation

* fix group issues

* docs: add groups
2026-03-20 10:46:09 +01:00

53 lines
1.4 KiB
TypeScript

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<CronQueuePayload>) {
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();
}
}
}