Update: 2026-07-09 01:01:15

This commit is contained in:
Hamza-Ayed
2026-07-09 01:01:16 +03:00
parent 6fe1d665e7
commit ac0c343f18
4 changed files with 380 additions and 1 deletions
+14 -1
View File
@@ -10,7 +10,7 @@
* Cron integration: see crontab examples in package.json scripts
*/
import { getMySQL, fetchSamples, saveFormulas, saveSurgeInsights, saveSurgeZones, closeConnections } from './db/connection';
import { getMySQL, fetchSamples, saveFormulas, saveFormulaHistory, saveSurgeInsights, saveSurgeZones, closeConnections } from './db/connection';
import { runAnalysis } from './analysis/engine';
import { Pool, RowDataPacket } from 'mysql2/promise';
@@ -236,6 +236,19 @@ async function processCompetitor(
if (peakHours.length > 0) {
console.log(` Peak hours stored: [${peakHours.join(', ')}]`);
}
// لقطة insert-only لمحرك الثبات (drift detection) — لا تُستبدل أبداً
await saveFormulaHistory(pool, formulas.map(f => ({
competitorName: f.competitorName,
countryCode: f.countryCode,
tier: f.tier,
baseFare: f.baseFare,
kmRate: f.kmRate,
minRate: f.minRate,
minFare: f.minFare,
rSquared: f.rSquared,
sampleCount: f.sampleCount,
})));
}
// --- Save surge insights ---