Update: 2026-07-06 19:17:19
This commit is contained in:
@@ -51,7 +51,7 @@ try {
|
||||
// 1. Economy tier (الأكثر تنافسية)
|
||||
// 2. Standard tier (إذا ما في Economy)
|
||||
// 3. أي tier ثاني بأعلى R²
|
||||
$tierPriority = ['economy', 'standard', 'premium'];
|
||||
$tierPriority = ['standard', 'economy', 'premium'];
|
||||
$bestFormula = null;
|
||||
$bestTierIdx = 999;
|
||||
|
||||
@@ -131,7 +131,8 @@ try {
|
||||
awfarPrice = :awfarPrice,
|
||||
normalMinPrice = :normalMin,
|
||||
peakMinPrice = :peakMin,
|
||||
lateMinPrice = :lateMin
|
||||
lateMinPrice = :lateMin,
|
||||
startPrice = :startPrice
|
||||
WHERE country = :countryName";
|
||||
|
||||
$upStmt = $con->prepare($updateSql);
|
||||
@@ -148,6 +149,7 @@ try {
|
||||
':normalMin' => $normalMin,
|
||||
':peakMin' => $peakMin,
|
||||
':lateMin' => $lateMin,
|
||||
':startPrice' => $ourBase,
|
||||
':countryName' => $countryName
|
||||
]);
|
||||
|
||||
@@ -230,4 +232,33 @@ try {
|
||||
echo " ❌ Error in Smart Retention: " . $e->getMessage() . "\n";
|
||||
}
|
||||
|
||||
// ==========================================
|
||||
// 4. Export AI Hotzones to Redis for Captains
|
||||
// ==========================================
|
||||
echo "4. Exporting AI Hotzones to Redis...\n";
|
||||
try {
|
||||
$sql = "SELECT latitude, longitude, competitor_name AS top_competitor, avg_ppk AS avg_price
|
||||
FROM competitor_surge_zones
|
||||
WHERE detected_at >= DATE_SUB(NOW(), INTERVAL 6 HOUR)
|
||||
AND surge_multiplier > 1.1";
|
||||
|
||||
$stmt = $con->query($sql);
|
||||
$zones = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
if (!empty($zones)) {
|
||||
$redisData = [
|
||||
'status' => 'success',
|
||||
'data' => $zones
|
||||
];
|
||||
$redis->setex('siro:cache:ai:hotzones', 3600, json_encode($redisData));
|
||||
echo " 🗺️ Exported " . count($zones) . " hot zones to Redis (siro:cache:ai:hotzones).\n";
|
||||
} else {
|
||||
// Clear if no surge to avoid stale data
|
||||
$redis->del('siro:cache:ai:hotzones');
|
||||
echo " ℹ️ No active hot zones to export.\n";
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
echo " ❌ Error in Hotzones Export: " . $e->getMessage() . "\n";
|
||||
}
|
||||
|
||||
echo "AI Engine v2 finished successfully.\n";
|
||||
|
||||
Reference in New Issue
Block a user