Add checking for hub slots. #651
This commit is contained in:
parent
d8f5b7833d
commit
b7c5f5dafe
1 changed files with 25 additions and 15 deletions
|
|
@ -4330,7 +4330,7 @@ class APIController extends Controller implements LoggedController
|
|||
// find the nearest hub
|
||||
if (!empty($nearest_hubs_with_distance))
|
||||
{
|
||||
// TODO: get slots of nearest hub right after getting nearest hub.
|
||||
// get slots of nearest hub right after getting nearest hub.
|
||||
// then check if hub has available slots. If not, get next nearest hub.
|
||||
foreach ($nearest_hubs_with_distance as $nhd)
|
||||
{
|
||||
|
|
@ -4339,20 +4339,26 @@ class APIController extends Controller implements LoggedController
|
|||
else
|
||||
{
|
||||
if ($nhd['distance'] < $nearest['distance'])
|
||||
$nearest = $nhd;
|
||||
{
|
||||
// get the slots for nearest which is nhd right now
|
||||
$hub_slots = $this->getHubRiderSlots($nhd['hub'], $em);
|
||||
|
||||
$flag_hub_available = $hub_slots['flag_hub_available'];
|
||||
|
||||
// if hub is available, set hub to nearest
|
||||
if ($flag_hub_available == true)
|
||||
{
|
||||
$nearest = $nhd;
|
||||
|
||||
// temporarily set hub_data to nearest
|
||||
$hub_data = [
|
||||
'hub' => $nhd['hub'],
|
||||
'slots' => $hub_slots['slot_data'],
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// get slots of nearest hub
|
||||
if ($nearest != null)
|
||||
{
|
||||
$hub_slots = $this->getHubRiderSlots($nearest['hub'], $em);
|
||||
|
||||
$hub_data = [
|
||||
'hub' => $nearest['hub'],
|
||||
'slots' => $hub_slots,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return $hub_data;
|
||||
|
|
@ -4477,6 +4483,8 @@ class APIController extends Controller implements LoggedController
|
|||
|
||||
$hub_slots = $this->generateHubSlots($hub_rider_slots, $slots);
|
||||
|
||||
error_log(print_r($hub_slots, true));
|
||||
|
||||
return $hub_slots;
|
||||
}
|
||||
|
||||
|
|
@ -4513,9 +4521,11 @@ class APIController extends Controller implements LoggedController
|
|||
}
|
||||
|
||||
// check if hub has available slots
|
||||
$hub_unavailable = false;
|
||||
$hub_available = true;
|
||||
error_log('total rider slots ' . $total_rslots);
|
||||
error_log('total unavailable slots ' . $total_unavailable_slots);
|
||||
if ($total_rslots == $total_unavailable_rslots)
|
||||
$hub_unavailable = true;
|
||||
$hub_available = false;
|
||||
|
||||
$hs_data = [
|
||||
'flag_hub_available' => $hub_unavailable,
|
||||
|
|
|
|||
Loading…
Reference in a new issue