chore: استيراد أولي من سيرو (ecfe7568) — بلا أي تعديل
نسخة كاملة من مستودع سيرو عند ecfe7568 لتكون أساس تطبيق «انطلق». نُسخ المتعقَّب في git فقط (12,509 ملفاً / 302 م.ب) بـ git archive، لا `cp -r` — فاستُثنيت تلقائياً مخلفات البناء (build · node_modules · .dart_tool · .gradle · Pods ≈ 10.7 غ.ب) وكل ما يستثنيه .gitignore. هذا الكوميت **بلا أي تعديل عمداً** حتى يكون كل ما يليه فرقاً مقروءاً مقابل سيرو الأصلي. سيرو نفسه لم يُمسّ. ⚠️ لا يبني بعد: `.env` و`lib/env/env.g.dart` غير متعقَّبين في سيرو (وهذا صحيح — أسرار لكل مستأجر). كل تطبيق فلاتر هنا يحتاج .env خاصاً بانطلق ثم توليد env.g.dart عبر build_runner. لا تُنسخ أسرار سيرو. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/**
|
||||
* get_surge_heatmap.php
|
||||
* يزود تطبيق الكابتن بأماكن الذروة وفرص الطلب الحالية
|
||||
*/
|
||||
|
||||
require_once __DIR__ . '/../../connect.php';
|
||||
|
||||
// Authentication happens in connect.php (JWT check)
|
||||
if (!isset($user_id) || $role !== 'driver') {
|
||||
http_response_code(403);
|
||||
echo json_encode(['status' => 'failure', 'message' => 'Unauthorized']);
|
||||
exit;
|
||||
}
|
||||
|
||||
try {
|
||||
$countryCode = filterRequest('country_code');
|
||||
if (!$countryCode) {
|
||||
$countryCode = 'SY'; // Fallback
|
||||
}
|
||||
|
||||
$surgeKey = "surge:opportunities:{$countryCode}";
|
||||
$hotspotsJson = $redis->get($surgeKey);
|
||||
$hotspots = $hotspotsJson ? json_decode($hotspotsJson, true) : [];
|
||||
|
||||
$driverHeatmap = [];
|
||||
|
||||
if (!empty($hotspots)) {
|
||||
foreach ($hotspots as $grid => $multiplier) {
|
||||
// Only show grids with a meaningful multiplier > 1.05
|
||||
if ($multiplier > 1.05) {
|
||||
list($lat, $lng) = explode('_', $grid);
|
||||
$driverHeatmap[] = [
|
||||
'lat' => (float)$lat,
|
||||
'lng' => (float)$lng,
|
||||
'surge_multiplier' => (float)$multiplier,
|
||||
'radius_meters' => 1500 // 1.5km grid box
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
jsonSuccess([
|
||||
'status' => 'success',
|
||||
'message' => 'Surge heatmap data fetched',
|
||||
'hotspots' => $driverHeatmap
|
||||
]);
|
||||
|
||||
} catch (Exception $e) {
|
||||
error_log("[get_surge_heatmap] Error: " . $e->getMessage());
|
||||
jsonError("Failed to fetch heatmap");
|
||||
}
|
||||
Reference in New Issue
Block a user