Make hub slot computation easier #399

This commit is contained in:
Kendrick Chan 2020-05-08 16:58:36 +08:00
parent 39dc9eff80
commit 475d91bc9e

View file

@ -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