Add dispatch time to rider time report #162

This commit is contained in:
Kendrick Chan 2018-09-14 15:59:51 +08:00
parent 7382b4333c
commit a0a1c664c2

View file

@ -38,7 +38,7 @@ class ReportRiderTime extends Command
protected function populateJOIndex()
{
$jo_events = $this->em->createQuery("select e from App\Entity\JOEvent e where e.date_create >= '20180905'")
$jo_events = $this->em->createQuery("select e from App\Entity\JOEvent e where e.date_create >= '20180805'")
->getResult();
// $jo_events = $this->em->getRepository(JOEvent::class)->findBy('date_create' => '20180905');
@ -51,7 +51,9 @@ class ReportRiderTime extends Command
if (!isset($this->jo_index[$jo_id]))
$this->jo_index[$jo_id] = [
'assign' => null,
'create' => $jo->getDateCreate(),
'hub_assign' => null,
'rider_assign' => null,
'fulfill' => null,
// 'data' => $jo,
'data' => [
@ -63,11 +65,17 @@ class ReportRiderTime extends Command
// only interested in fulfilled and rider_assign
switch ($jo_event->getTypeID())
{
case JOEventType::CREATE:
$this->jo_index[$jo_id]['create'] = $jo_event->getDateHappen();
break;
case JOEventType::HUB_ASSIGN:
$this->jo_index[$jo_id]['hub_assign'] = $jo_event->getDateHappen();
break;
case JOEventType::RIDER_ASSIGN:
$this->jo_index[$jo->getID()]['assign'] = $jo_event->getDateHappen();
$this->jo_index[$jo_id]['rider_assign'] = $jo_event->getDateHappen();
break;
case JOEventType::FULFILL:
$this->jo_index[$jo->getID()]['fulfill'] = $jo_event->getDateHappen();
$this->jo_index[$jo_id]['fulfill'] = $jo_event->getDateHappen();
break;
}
}
@ -81,12 +89,13 @@ class ReportRiderTime extends Command
foreach ($this->jo_index as $index => $joi)
{
if($joi['assign'] != null && $joi['fulfill'] != null)
if($joi['rider_assign'] != null && $joi['fulfill'] != null)
{
$this->filtered_jo_index[$index] = $joi;
$interval = $joi['fulfill']->diff($joi['assign']);
$this->filtered_jo_index[$index]['seconds'] = $joi['fulfill']->getTimestamp() - $joi['assign']->getTimestamp();
$interval = $joi['fulfill']->diff($joi['rider_assign']);
$this->filtered_jo_index[$index]['dispatch_secs'] = $joi['hub_assign']->getTimestamp() - $joi['create']->getTimestamp();
$this->filtered_jo_index[$index]['seconds'] = $joi['fulfill']->getTimestamp() - $joi['rider_assign']->getTimestamp();
}
}
}
@ -114,6 +123,7 @@ class ReportRiderTime extends Command
fputcsv($fh, [
$joi['data']['id'],
$joi['data']['date_schedule']->format('Y-m-d'),
$joi['dispatch_secs'],
$joi['seconds'],
]);
}