Fix driver visibility radius and silence tolerance in api_get_nearby

This commit is contained in:
Hamza-Ayed
2026-07-22 15:45:54 +03:00
parent 901f429b9c
commit 09a4bbc79f
5 changed files with 68 additions and 14 deletions
+4 -4
View File
@@ -37,7 +37,7 @@ if (!empty($INTERNAL_KEY) && $receivedKey !== $INTERNAL_KEY) {
$lat = $_REQUEST['lat'] ?? null;
$lng = $_REQUEST['lng'] ?? null;
$radius = $_REQUEST['radius'] ?? 5;
$radius = $_REQUEST['radius'] ?? 25;
$limit = $_REQUEST['limit'] ?? 100;
if (!$lat || !$lng) {
@@ -67,7 +67,7 @@ try {
$validDrivers = [];
$currentTime = time();
$max_silence = 180;
$max_silence = 900; // 15 دقيقة سماحية للسائق المنتظر في مكانه
foreach ($geoResults as $res) {
// هيكل النتيجة مع WITHCOORD يختلف قليلاً
@@ -76,9 +76,9 @@ try {
$d_coord= $res[2]; // [0=>lng, 1=>lat] 🔥 الإحداثيات هنا
$profile = $redis->hgetall("driver:profile:$d_id");
$lastUpdate = isset($profile['updated_at']) ? (int)$profile['updated_at'] : 0;
$lastUpdate = isset($profile['updated_at']) ? (int)$profile['updated_at'] : $currentTime;
if (empty($profile) || ($currentTime - $lastUpdate) > $max_silence) {
if (!empty($lastUpdate) && ($currentTime - $lastUpdate) > $max_silence) {
$redis->zrem('geo:drivers:available', $d_id);
$redis->zrem('geo:drivers:busy', $d_id);
continue;