From 475d91bc9e3747121cbdccc28f18a807cf11a4fb Mon Sep 17 00:00:00 2001 From: Kendrick Chan Date: Fri, 8 May 2020 16:58:36 +0800 Subject: [PATCH] Make hub slot computation easier #399 --- src/Controller/APIController.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Controller/APIController.php b/src/Controller/APIController.php index ab540ca5..4c8b27f9 100644 --- a/src/Controller/APIController.php +++ b/src/Controller/APIController.php @@ -2976,21 +2976,31 @@ class APIController extends Controller implements LoggedController protected function getHubRiderSlots(Hub $hub, EntityManagerInterface $em) { // check hub's advance orders for the day + + /* // get number of advance orders for the next day if request came in before midnight // or for current day if request came in after midnight // check request_time $request_time = time(); $midnight = strtotime('00:00'); + */ $start_date = new DateTime(); $end_date = new DateTime(); + // to keep things simple, just start on next day regardless of midnight timer + $start_date->add(new DateInterval('P1D')); + $end_date->add(new DateInterval('P3D')); + + /* if ($request_time < $midnight) { // add +1 to start date to get the next day // add +3 to date to end date to get the advance orders for the next three days $start_date->add(new DateInterval('P1D')); + $end_date->add(new DateInterval('P1D')); } $end_date->add(new DateInterval('P2D')); + */ // set time bounds for the start and end date $start_date->setTime(0, 1); @@ -3013,6 +3023,7 @@ class APIController extends Controller implements LoggedController 'status_fulfilled' => JOStatus::FULFILLED, ]) ->getResult(); + // check request_time // check each JO's date_schedule, decrement rider_slots if date schedule falls in that slot // index - equivalent time