How often to run aggregation (in minutes, default: 60)
Promise that resolves when service is started and initial aggregation completes
export async function startSkipMetricsCollection(intervalMinutes = 60) {
if (isCollecting) {
return;
}
isCollecting = true;
saveLog("Started skip metrics collection service", "INFO");
// Run an initial aggregation immediately
try {
await runAggregation();
} catch (error) {
saveLog(`Error during initial skip metrics aggregation: ${error}`, "ERROR");
}
// Set up the interval for regular aggregation
const intervalMs = intervalMinutes * 60 * 1000;
aggregationInterval = setInterval(async () => {
try {
await runAggregation();
} catch (error) {
saveLog(
`Error during scheduled skip metrics aggregation: ${error}`,
"ERROR",
);
}
}, intervalMs);
}
Starts the background skip metrics collection service
Initializes and schedules regular background processing of listening data into statistical aggregations. Runs an immediate aggregation upon startup, then schedules recurring aggregations at the specified interval.
The service consolidates all aggregation operations, including: