stock aggregate table

This commit is contained in:
Thanakorn S
2026-05-25 13:30:10 +07:00
parent 293097363b
commit ba96de50a1
20 changed files with 725 additions and 62 deletions
+25 -1
View File
@@ -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)');