From 457bbece2bdb1c04adcfb05944799b9fb458a7eb Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Thu, 24 Mar 2022 05:28:15 +0000 Subject: [PATCH] Fix issues found while testing. #651 --- src/Controller/APIController.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/Controller/APIController.php b/src/Controller/APIController.php index 5d6b16d2..3e4d2906 100644 --- a/src/Controller/APIController.php +++ b/src/Controller/APIController.php @@ -4326,6 +4326,7 @@ class APIController extends Controller implements LoggedController } $nearest = null; + $hub_slots = []; $slot_found = false; // find the nearest hub if (!empty($nearest_hubs_with_distance)) @@ -4349,18 +4350,18 @@ class APIController extends Controller implements LoggedController if ($flag_hub_available == true) { $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; } @@ -4525,7 +4526,10 @@ class APIController extends Controller implements LoggedController error_log('total rider slots ' . $total_rslots); error_log('total unavailable slots ' . $total_unavailable_slots); if ($total_rslots == $total_unavailable_rslots) + { + error_log('hub has no available slots'); $hub_available = false; + } $hs_data = [ 'flag_hub_available' => $hub_unavailable,