From e9fa25dadaca8778b62a29bbab63e761ae7a636d Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Wed, 20 Oct 2021 06:45:12 +0000 Subject: [PATCH] Fix sending of rider event when JO is requeued. #630 --- .../UpdateUnacceptedJobOrdersCommand.php | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/Command/UpdateUnacceptedJobOrdersCommand.php b/src/Command/UpdateUnacceptedJobOrdersCommand.php index a19a34c9..12dc6636 100644 --- a/src/Command/UpdateUnacceptedJobOrdersCommand.php +++ b/src/Command/UpdateUnacceptedJobOrdersCommand.php @@ -53,7 +53,7 @@ class UpdateUnacceptedJobOrdersCommand extends Command // that will be updated // need rider id to set rider to available since rider becomes unavailable // the minute JO is assigned to rider - $query_sql = 'SELECT id, rider_id FROM job_order WHERE status = :current_status and TIMESTAMPDIFF(MINUTE, date_assign, NOW()) >= :timeout'; + $query_sql = 'SELECT id FROM job_order WHERE status = :current_status and TIMESTAMPDIFF(MINUTE, date_assign, NOW()) >= :timeout'; $query_stmt = $db->prepare($query_sql); $query_stmt->execute([ @@ -66,12 +66,14 @@ class UpdateUnacceptedJobOrdersCommand extends Command while ($row = $query_stmt->fetch(PDO::FETCH_NUM)) { // $row[0] is the jo id - // $row[1] is the rider id - // store the ids for now for the event sending after update of JOs + // store the jos for now for the event sending after update of JOs // and the updating of rider's availability + $jo_id = $row[0]; + + $requeued_jo = $em->getRepository(JobOrder::class)->find($jo_id); + $requeued_jos[] = [ - 'jo_id' => $row[0], - 'rider_id' => $row[1], + 'jo' => $requeued_jo, ]; } @@ -88,10 +90,7 @@ class UpdateUnacceptedJobOrdersCommand extends Command foreach ($requeued_jos as $jo_info) { - $jo_id = $jo_info['jo_id']; - $rider_id = $jo_info['rider_id']; - - $jo = $em->getRepository(JobOrder::class)->find($jo_id); + $jo = $jo_info['jo']; if ($jo != null) { $output->writeln('Requeuing for rider assignment ' . $jo->getID()); @@ -113,7 +112,7 @@ class UpdateUnacceptedJobOrdersCommand extends Command $mclient->sendEvent($jo, $payload); } - $rider = $em->getRepository(Rider::class)->find($rider_id); + $rider = $jo->getRider(); if ($rider != null) { // set rider's availability to true