Merge branch '162-phase-2-changes' into 'master'
Modify rider report to accept date range #162 Closes #162 See merge request jankstudio/resq!192
This commit is contained in:
commit
3a29f2250d
1 changed files with 17 additions and 4 deletions
|
|
@ -33,12 +33,18 @@ class ReportRiderTime extends Command
|
|||
$this->setName('report:rider-time')
|
||||
->setDescription('Generate CSV file with report on rider time.')
|
||||
->setHelp('Generate report on rider time from assignment to fulfilled.')
|
||||
->addArgument('file', InputArgument::REQUIRED, 'Path to the output CSV file.');
|
||||
->addArgument('file', InputArgument::REQUIRED, 'Path to the output CSV file.')
|
||||
->addArgument('date_from', InputArgument::REQUIRED, 'Date from.')
|
||||
->addArgument('date_to', InputArgument::REQUIRED, 'Date to.');
|
||||
}
|
||||
|
||||
protected function populateJOIndex()
|
||||
protected function populateJOIndex($date_from, $date_to)
|
||||
{
|
||||
$jo_events = $this->em->createQuery("select e from App\Entity\JOEvent e where e.date_create >= '20180805'")
|
||||
$jo_events = $this->em->createQuery("select e from App\Entity\JOEvent e where e.date_create >= :dfrom and e.date_create <= :dto")
|
||||
->setParameters([
|
||||
'dfrom' => '20180805',
|
||||
'dto' => '20180920',
|
||||
])
|
||||
->getResult();
|
||||
// $jo_events = $this->em->getRepository(JOEvent::class)->findBy('date_create' => '20180905');
|
||||
|
||||
|
|
@ -89,6 +95,11 @@ class ReportRiderTime extends Command
|
|||
|
||||
foreach ($this->jo_index as $index => $joi)
|
||||
{
|
||||
// no hub assign because they used re-assign right away
|
||||
// TODO: fix so we take this into account
|
||||
if ($joi['hub_assign'] == null)
|
||||
continue;
|
||||
|
||||
if($joi['rider_assign'] != null && $joi['fulfill'] != null)
|
||||
{
|
||||
$this->filtered_jo_index[$index] = $joi;
|
||||
|
|
@ -104,6 +115,8 @@ class ReportRiderTime extends Command
|
|||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$csv_file = $input->getArgument('file');
|
||||
$date_from = $input->getArgument('date_from');
|
||||
$date_to = $input->getArgument('date_to');
|
||||
|
||||
// attempt to open file
|
||||
try
|
||||
|
|
@ -115,7 +128,7 @@ class ReportRiderTime extends Command
|
|||
throw new Exception('The file "' . $csv_file . '" could be opened.');
|
||||
}
|
||||
|
||||
$this->populateJOIndex();
|
||||
$this->populateJOIndex($date_from, $date_to);
|
||||
$this->filterJOIndex();
|
||||
|
||||
foreach ($this->filtered_jo_index as $joi)
|
||||
|
|
|
|||
Loading…
Reference in a new issue