wip
This commit is contained in:
@@ -34,6 +34,11 @@ export async function bootCron() {
|
||||
type: 'flushSessions',
|
||||
pattern: 1000 * 10,
|
||||
},
|
||||
{
|
||||
name: 'insightsDaily',
|
||||
type: 'insightsDaily',
|
||||
pattern: '0 2 * * *',
|
||||
},
|
||||
];
|
||||
|
||||
if (process.env.SELF_HOSTED && process.env.NODE_ENV === 'production') {
|
||||
@@ -44,12 +49,6 @@ export async function bootCron() {
|
||||
});
|
||||
}
|
||||
|
||||
jobs.push({
|
||||
name: 'insightsDaily',
|
||||
type: 'insightsDaily',
|
||||
pattern: '0 2 * * *', // 2 AM daily
|
||||
});
|
||||
|
||||
logger.info('Updating cron jobs');
|
||||
|
||||
const jobSchedulers = await cronQueue.getJobSchedulers();
|
||||
|
||||
@@ -79,11 +79,6 @@ async function start() {
|
||||
await bootCron();
|
||||
} else {
|
||||
logger.warn('Workers are disabled');
|
||||
|
||||
// Start insights worker
|
||||
const insightsWorker = new Worker(insightsQueue.name, insightsProjectJob, {
|
||||
connection: getRedisQueue(),
|
||||
});
|
||||
}
|
||||
|
||||
await createInitialSalts();
|
||||
|
||||
@@ -16,7 +16,7 @@ import { insightsQueue } from '@openpanel/queue';
|
||||
import type { Job } from 'bullmq';
|
||||
|
||||
const defaultEngineConfig = {
|
||||
keepTopNPerModuleWindow: 5,
|
||||
keepTopNPerModuleWindow: 20,
|
||||
closeStaleAfterDays: 7,
|
||||
dimensionBatchSize: 50,
|
||||
globalThresholds: {
|
||||
@@ -24,8 +24,6 @@ const defaultEngineConfig = {
|
||||
minAbsDelta: 80,
|
||||
minPct: 0.15,
|
||||
},
|
||||
enableExplain: false,
|
||||
explainTopNPerProjectPerDay: 3,
|
||||
};
|
||||
|
||||
export async function insightsDailyJob(job: Job<CronQueuePayload>) {
|
||||
@@ -63,9 +61,12 @@ export async function insightsProjectJob(
|
||||
config: defaultEngineConfig,
|
||||
});
|
||||
|
||||
const projectCreatedAt = await insightStore.getProjectCreatedAt(projectId);
|
||||
|
||||
await engine.runProject({
|
||||
projectId,
|
||||
cadence: 'daily',
|
||||
now: new Date(date),
|
||||
projectCreatedAt,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user