Fix issues found while testing. #651

This commit is contained in:
Korina Cordero 2022-03-24 05:28:15 +00:00
parent b7c5f5dafe
commit 457bbece2b

View file

@ -4326,6 +4326,7 @@ class APIController extends Controller implements LoggedController
} }
$nearest = null; $nearest = null;
$hub_slots = [];
$slot_found = false; $slot_found = false;
// find the nearest hub // find the nearest hub
if (!empty($nearest_hubs_with_distance)) if (!empty($nearest_hubs_with_distance))
@ -4349,18 +4350,18 @@ class APIController extends Controller implements LoggedController
if ($flag_hub_available == true) if ($flag_hub_available == true)
{ {
$nearest = $nhd; $nearest = $nhd;
// temporarily set hub_data to nearest
$hub_data = [
'hub' => $nhd['hub'],
'slots' => $hub_slots['slot_data'],
];
} }
} }
} }
} }
} }
// set hub data to what is in nearest
$hub_data = [
'hub' => $nearest['hub'],
'slots' => $hub_slots['slot_data'],
];
return $hub_data; return $hub_data;
} }
@ -4525,7 +4526,10 @@ class APIController extends Controller implements LoggedController
error_log('total rider slots ' . $total_rslots); error_log('total rider slots ' . $total_rslots);
error_log('total unavailable slots ' . $total_unavailable_slots); error_log('total unavailable slots ' . $total_unavailable_slots);
if ($total_rslots == $total_unavailable_rslots) if ($total_rslots == $total_unavailable_rslots)
{
error_log('hub has no available slots');
$hub_available = false; $hub_available = false;
}
$hs_data = [ $hs_data = [
'flag_hub_available' => $hub_unavailable, 'flag_hub_available' => $hub_unavailable,