stock aggregate table
This commit is contained in:
+25
-1
@@ -64,4 +64,28 @@ cron.schedule('0 * * * *', async () => {
|
||||
}
|
||||
});
|
||||
|
||||
console.log('[scheduler] running — etl_gl_maintenance wired (hourly, slot-based)');
|
||||
// ── ETL Stock Summary maintenance — runs every hour ──────────────────────────
|
||||
// Checks and repairs etl_stock_summary (stock aggregation table).
|
||||
// Same slot-based distribution as GL: company_id % 24.
|
||||
cron.schedule('30 * * * *', async () => {
|
||||
const slot = new Date().getHours();
|
||||
console.log(`[scheduler] etl_stock slot=${slot}`);
|
||||
|
||||
try {
|
||||
const result = await callPhp('/cron/etl_stock_maintenance.php', { slot });
|
||||
const summary = (result.results || []).map(r =>
|
||||
r.error
|
||||
? `company=${r.company_id} ERROR: ${r.error}`
|
||||
: `company=${r.company_id} gaps=${r.gaps_found} rebuilt=${r.periods_rebuilt}`
|
||||
);
|
||||
if (summary.length === 0) {
|
||||
console.log(`[scheduler] etl_stock slot=${slot} — no companies`);
|
||||
} else {
|
||||
summary.forEach(s => console.log(`[scheduler] etl_stock ${s}`));
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('[scheduler] etl_stock_maintenance failed:', e.message);
|
||||
}
|
||||
});
|
||||
|
||||
console.log('[scheduler] running — etl_gl_maintenance + etl_stock_maintenance wired (hourly, slot-based)');
|
||||
|
||||
Reference in New Issue
Block a user