From 0065bc94ef009f27425c00abac60a17ec2c392a5 Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Tue, 19 Oct 2021 06:41:53 +0000 Subject: [PATCH 01/11] Add index for status for job order. Add command to update the status and rider for unaccepted job orders. #630 --- .../UpdateUnacceptedJobOrdersCommand.php | 58 +++++++++++++++++++ src/Controller/APIController.php | 2 + src/Entity/JobOrder.php | 3 +- 3 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 src/Command/UpdateUnacceptedJobOrdersCommand.php diff --git a/src/Command/UpdateUnacceptedJobOrdersCommand.php b/src/Command/UpdateUnacceptedJobOrdersCommand.php new file mode 100644 index 00000000..8a52f4b8 --- /dev/null +++ b/src/Command/UpdateUnacceptedJobOrdersCommand.php @@ -0,0 +1,58 @@ +em = $em; + + parent::__construct(); + } + + protected function configure() + { + $this->setName('joborder:reassignunaccepted') + ->setDescription('Requeue for rider assignment assigned but unaccepted job orders that have been assigned for more than 3 mins.') + ->setHelp('Requeue for rider assignment assigned but unaccepted job orders that have been assigned for more than 3 mins.'); + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $em = $this->em; + + // TODO: get the timeout limit from .env + $timeout = 3; + + // pdo connection + $db = $em->getConnection(); + + // update the assigned job orders and have been unaccepted for at least 3 minutes + // change the jo status from assigned to rider_assign and rider id to null + $sql = 'UPDATE job_order SET status=:jo_status, rider_id=null WHERE status=\'assigned\' and TIMESTAMPDIFF(MINUTE, date_assign, NOW()) >= :timeout'; + + $stmt = $db->prepare($sql); + $stmt->execute([ + 'jo_status' => 'rider_assign', + 'timeout' => $timeout, + ]); + + // send notifications to rider app, telling rider that jo has been requeued + + // send notification to mobile app for customer, telling customer that jo has been requeued + + return 0; + } +} diff --git a/src/Controller/APIController.php b/src/Controller/APIController.php index f9f0b596..dd5ec30d 100644 --- a/src/Controller/APIController.php +++ b/src/Controller/APIController.php @@ -2957,6 +2957,8 @@ class APIController extends Controller implements LoggedController $jo->setStatusAutoAssign(AutoAssignStatus::HUB_AND_RIDER_ASSIGNED); $jo->setDeliveryStatus(DeliveryStatus::RIDER_ASSIGN); + // TODO: set date_assigned for job order + $assigned_rider->setAvailable(false); // set rider's current job order diff --git a/src/Entity/JobOrder.php b/src/Entity/JobOrder.php index fcbe5ddc..b2dc6f27 100644 --- a/src/Entity/JobOrder.php +++ b/src/Entity/JobOrder.php @@ -21,7 +21,8 @@ use App\Ramcar\WillingToWaitContent; * @ORM\Index(name="plate_number_idx", columns={"plate_number"}), * @ORM\Index(name="first_name_idx", columns={"first_name"}), * @ORM\Index(name="last_name_idx", columns={"last_name"}), - * @ORM\Index(name="phone_mobile_idx", columns={"phone_mobile"}) + * @ORM\Index(name="phone_mobile_idx", columns={"phone_mobile"}), + * @ORM\Index(name="status_idx", columns={"status"}), * }) */ class JobOrder From c2066b86c9dc411a4a284758c00de049ed792fe6 Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Tue, 19 Oct 2021 09:19:27 +0000 Subject: [PATCH 02/11] Add retrieval of job orders to be updated. #630 --- .../UpdateUnacceptedJobOrdersCommand.php | 67 ++++++++++++++++--- 1 file changed, 58 insertions(+), 9 deletions(-) diff --git a/src/Command/UpdateUnacceptedJobOrdersCommand.php b/src/Command/UpdateUnacceptedJobOrdersCommand.php index 8a52f4b8..b4bed2f3 100644 --- a/src/Command/UpdateUnacceptedJobOrdersCommand.php +++ b/src/Command/UpdateUnacceptedJobOrdersCommand.php @@ -9,15 +9,21 @@ use Symfony\Component\Console\Output\OutputInterface; use Doctrine\ORM\EntityManagerInterface; +use App\Service\MQTTClient; + use App\Entity\JobOrder; +use PDO; + class UpdateUnacceptedJobOrdersCommand extends Command { protected $em; + protected $mclient; - public function __construct(EntityManagerInterface $em) + public function __construct(EntityManagerInterface $em, MQTTClient $mclient) { $this->em = $em; + $this->mclient = $mclient; parent::__construct(); } @@ -32,26 +38,69 @@ class UpdateUnacceptedJobOrdersCommand extends Command protected function execute(InputInterface $input, OutputInterface $output) { $em = $this->em; + $mclient = $this->mclient; // TODO: get the timeout limit from .env $timeout = 3; + $current_status = 'assigned'; + $new_status = 'rider_assign'; // pdo connection $db = $em->getConnection(); - // update the assigned job orders and have been unaccepted for at least 3 minutes - // change the jo status from assigned to rider_assign and rider id to null - $sql = 'UPDATE job_order SET status=:jo_status, rider_id=null WHERE status=\'assigned\' and TIMESTAMPDIFF(MINUTE, date_assign, NOW()) >= :timeout'; + // since we need the actual job orders for mqtt events, we need to get the ids of the job orders + // that will be updated + $query_sql = 'SELECT id, rider_id FROM job_order WHERE status = :current_status and TIMESTAMPDIFF(MINUTE, date_assign, NOW()) >= :timeout'; - $stmt = $db->prepare($sql); - $stmt->execute([ - 'jo_status' => 'rider_assign', + $query_stmt = $db->prepare($query_sql); + $query_stmt->execute([ + 'current_status' => $current_status, 'timeout' => $timeout, ]); - // send notifications to rider app, telling rider that jo has been requeued + // go through rows + $requeued_jos = []; + 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, until the jos have been updated + $requeued_jos[] = [ + 'jo_id' => $row[0], + 'rider_id' => $row[1], + ]; + } - // send notification to mobile app for customer, telling customer that jo has been requeued + // update the assigned job orders and have been unaccepted for at least 3 minutes + // change the jo status from assigned to rider_assign and rider id to null + $update_sql = 'UPDATE job_order SET status = :new_status, rider_id = null WHERE status = :current_status and TIMESTAMPDIFF(MINUTE, date_assign, NOW()) >= :timeout'; + + $update_stmt = $db->prepare($update_sql); + $update_stmt->execute([ + 'new_status' => $new_status, + 'current_status' => $current_status, + 'timeout' => $timeout, + ]); + + 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); + if ($jo != null) + { + $output->writeln($jo->getID()); + // send notifications to rider app, telling rider that jo has been requeued + + + // send notification to mobile app for customer, telling customer that jo has been requeued + //$mobile_payload = [ + //]; + + //$mclient->sendEvent(); + } + } return 0; } From d36610638166b5bbfd1f192a3616b6e66551b333 Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Wed, 20 Oct 2021 05:34:43 +0000 Subject: [PATCH 03/11] Add sending of mqtt events. #630 --- .../UpdateUnacceptedJobOrdersCommand.php | 28 +++++++++++-------- .../ResqRiderAssignmentHandler.php | 2 ++ 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/Command/UpdateUnacceptedJobOrdersCommand.php b/src/Command/UpdateUnacceptedJobOrdersCommand.php index b4bed2f3..0a863334 100644 --- a/src/Command/UpdateUnacceptedJobOrdersCommand.php +++ b/src/Command/UpdateUnacceptedJobOrdersCommand.php @@ -50,7 +50,7 @@ class UpdateUnacceptedJobOrdersCommand extends Command // since we need the actual job orders for mqtt events, we need to get the ids of the job orders // that will be updated - $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([ @@ -63,11 +63,9 @@ 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, until the jos have been updated + // store the ids for now for the event sending after update of JOs $requeued_jos[] = [ 'jo_id' => $row[0], - 'rider_id' => $row[1], ]; } @@ -90,15 +88,23 @@ class UpdateUnacceptedJobOrdersCommand extends Command $jo = $em->getRepository(JobOrder::class)->find($jo_id); if ($jo != null) { - $output->writeln($jo->getID()); + $output->writeln('Requeuing for rider assignmen ' . $jo->getID()); + $id = $jo->getID(); + // send notifications to rider app, telling rider that jo has been requeued - + $rider_payload = [ + 'event' => 'cancelled', + 'reason' => 'Reassigned', + 'jo_id' => $id, + ]; + $mclient->sendRiderEvent($jo, $rider_payload); - // send notification to mobile app for customer, telling customer that jo has been requeued - //$mobile_payload = [ - //]; - - //$mclient->sendEvent(); + // send outlet assign since order should go back to hub and await reassignment to another rider + $payload = [ + 'event' => 'outlet_assign', + 'jo_id' => $id, + ]; + $mclient->sendEvent($jo, $payload); } } diff --git a/src/Service/RiderAssignmentHandler/ResqRiderAssignmentHandler.php b/src/Service/RiderAssignmentHandler/ResqRiderAssignmentHandler.php index 0b101a17..ddaf985e 100644 --- a/src/Service/RiderAssignmentHandler/ResqRiderAssignmentHandler.php +++ b/src/Service/RiderAssignmentHandler/ResqRiderAssignmentHandler.php @@ -50,6 +50,8 @@ class ResqRiderAssignmentHandler implements RiderAssignmentHandlerInterface // send push notification $this->aclient->sendPush($obj, "A RESQ rider is on his way to you."); + + $this->em->flush(); } } From 9b7852d248d0a5afede8bdfdf41aff4e9c07c35c Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Wed, 20 Oct 2021 05:42:05 +0000 Subject: [PATCH 04/11] Remove rider id from command. #630 --- src/Command/UpdateUnacceptedJobOrdersCommand.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Command/UpdateUnacceptedJobOrdersCommand.php b/src/Command/UpdateUnacceptedJobOrdersCommand.php index 0a863334..6533cf23 100644 --- a/src/Command/UpdateUnacceptedJobOrdersCommand.php +++ b/src/Command/UpdateUnacceptedJobOrdersCommand.php @@ -83,7 +83,6 @@ 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); if ($jo != null) From f8ebe0d97a34a119a025b6509a93153321ed602e Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Wed, 20 Oct 2021 06:19:59 +0000 Subject: [PATCH 05/11] Set rider's availability after JOs are requeued. #630 --- .../UpdateUnacceptedJobOrdersCommand.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/Command/UpdateUnacceptedJobOrdersCommand.php b/src/Command/UpdateUnacceptedJobOrdersCommand.php index 6533cf23..dae3f962 100644 --- a/src/Command/UpdateUnacceptedJobOrdersCommand.php +++ b/src/Command/UpdateUnacceptedJobOrdersCommand.php @@ -50,7 +50,9 @@ class UpdateUnacceptedJobOrdersCommand extends Command // since we need the actual job orders for mqtt events, we need to get the ids of the job orders // that will be updated - $query_sql = 'SELECT id FROM job_order WHERE status = :current_status and TIMESTAMPDIFF(MINUTE, date_assign, NOW()) >= :timeout'; + // 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_stmt = $db->prepare($query_sql); $query_stmt->execute([ @@ -63,9 +65,12 @@ 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 + // and the updating of rider's availability $requeued_jos[] = [ 'jo_id' => $row[0], + 'rider_id' => $row[1], ]; } @@ -83,11 +88,12 @@ 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); if ($jo != null) { - $output->writeln('Requeuing for rider assignmen ' . $jo->getID()); + $output->writeln('Requeuing for rider assignment ' . $jo->getID()); $id = $jo->getID(); // send notifications to rider app, telling rider that jo has been requeued @@ -105,8 +111,17 @@ class UpdateUnacceptedJobOrdersCommand extends Command ]; $mclient->sendEvent($jo, $payload); } + + $rider = $em->getRepository(Rider::class)->find($rider_id); + if ($rider != null) + { + // set rider's availability to true + $rider->setAvailable(true); + } } + $em->flush(); + return 0; } } From c955516acf6bf63b212fbb0af1a72b200121721b Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Wed, 20 Oct 2021 06:28:31 +0000 Subject: [PATCH 06/11] Fix testing issues found. #630 --- src/Command/UpdateUnacceptedJobOrdersCommand.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Command/UpdateUnacceptedJobOrdersCommand.php b/src/Command/UpdateUnacceptedJobOrdersCommand.php index dae3f962..a19a34c9 100644 --- a/src/Command/UpdateUnacceptedJobOrdersCommand.php +++ b/src/Command/UpdateUnacceptedJobOrdersCommand.php @@ -12,6 +12,7 @@ use Doctrine\ORM\EntityManagerInterface; use App\Service\MQTTClient; use App\Entity\JobOrder; +use App\Entity\Rider; use PDO; From e9fa25dadaca8778b62a29bbab63e761ae7a636d Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Wed, 20 Oct 2021 06:45:12 +0000 Subject: [PATCH 07/11] 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 From 9f5493c1256e72813c3a59bc2dc9988b67299a3b Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Fri, 22 Oct 2021 06:59:55 +0000 Subject: [PATCH 08/11] Remove debug logs. Update rider's current job order when JO is requeued. #630 --- src/Command/UpdateUnacceptedJobOrdersCommand.php | 5 ++++- src/Service/MQTTClient.php | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Command/UpdateUnacceptedJobOrdersCommand.php b/src/Command/UpdateUnacceptedJobOrdersCommand.php index 12dc6636..a8ea5a3a 100644 --- a/src/Command/UpdateUnacceptedJobOrdersCommand.php +++ b/src/Command/UpdateUnacceptedJobOrdersCommand.php @@ -93,7 +93,7 @@ class UpdateUnacceptedJobOrdersCommand extends Command $jo = $jo_info['jo']; if ($jo != null) { - $output->writeln('Requeuing for rider assignment ' . $jo->getID()); + // $output->writeln('Requeuing for rider assignment ' . $jo->getID()); $id = $jo->getID(); // send notifications to rider app, telling rider that jo has been requeued @@ -117,6 +117,9 @@ class UpdateUnacceptedJobOrdersCommand extends Command { // set rider's availability to true $rider->setAvailable(true); + + // set rider's current job order to null + $rider->setCurrentJobOrder(); } } diff --git a/src/Service/MQTTClient.php b/src/Service/MQTTClient.php index 13c884a0..00229f5f 100644 --- a/src/Service/MQTTClient.php +++ b/src/Service/MQTTClient.php @@ -35,8 +35,8 @@ class MQTTClient public function sendEvent(JobOrder $job_order, $payload) { - error_log('sending mqtt event: '); - error_log(print_r($payload, true)); + //error_log('sending mqtt event: '); + //error_log(print_r($payload, true)); $sessions = $job_order->getCustomer()->getMobileSessions(); if (count($sessions) == 0) From f9de11ccb5066fbbabac236296b81cc7cdb1918a Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Mon, 8 Nov 2021 05:36:59 +0000 Subject: [PATCH 09/11] Fix the command to update unaccepted job orders. Add more checking before updating rider's availability. #630 --- .../UpdateUnacceptedJobOrdersCommand.php | 37 +++++++++++-------- src/Controller/RiderController.php | 2 + 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/src/Command/UpdateUnacceptedJobOrdersCommand.php b/src/Command/UpdateUnacceptedJobOrdersCommand.php index a8ea5a3a..b23eb215 100644 --- a/src/Command/UpdateUnacceptedJobOrdersCommand.php +++ b/src/Command/UpdateUnacceptedJobOrdersCommand.php @@ -75,25 +75,21 @@ class UpdateUnacceptedJobOrdersCommand extends Command $requeued_jos[] = [ 'jo' => $requeued_jo, ]; + + $update_sql = 'UPDATE job_order SET status = :new_status, rider_id = null WHERE id = :jo_id'; + $update_stmt = $db->prepare($update_sql); + $update_stmt->execute([ + 'new_status' => $new_status, + 'jo_id' => $jo_id, + ]); } - // update the assigned job orders and have been unaccepted for at least 3 minutes - // change the jo status from assigned to rider_assign and rider id to null - $update_sql = 'UPDATE job_order SET status = :new_status, rider_id = null WHERE status = :current_status and TIMESTAMPDIFF(MINUTE, date_assign, NOW()) >= :timeout'; - - $update_stmt = $db->prepare($update_sql); - $update_stmt->execute([ - 'new_status' => $new_status, - 'current_status' => $current_status, - 'timeout' => $timeout, - ]); - foreach ($requeued_jos as $jo_info) { $jo = $jo_info['jo']; if ($jo != null) { - // $output->writeln('Requeuing for rider assignment ' . $jo->getID()); + $output->writeln('Requeuing for rider assignment ' . $jo->getID()); $id = $jo->getID(); // send notifications to rider app, telling rider that jo has been requeued @@ -104,6 +100,7 @@ class UpdateUnacceptedJobOrdersCommand extends Command ]; $mclient->sendRiderEvent($jo, $rider_payload); + // send outlet assign since order should go back to hub and await reassignment to another rider $payload = [ 'event' => 'outlet_assign', @@ -115,11 +112,19 @@ class UpdateUnacceptedJobOrdersCommand extends Command $rider = $jo->getRider(); if ($rider != null) { - // set rider's availability to true - $rider->setAvailable(true); + // check rider's current job order before changing rider's availability + // since rider's current job order is set when JO is assigned to rider + if ($rider->getCurrentJobOrder() != null) + { + if ($rider->getCurrentJobOrder()->getID() == $jo->getID()) + { + // reset rider's availability to true + $rider->setAvailable(true); - // set rider's current job order to null - $rider->setCurrentJobOrder(); + // set rider's current job order to null + $rider->setCurrentJobOrder(); + } + } } } diff --git a/src/Controller/RiderController.php b/src/Controller/RiderController.php index b7d7fadd..c53ac626 100644 --- a/src/Controller/RiderController.php +++ b/src/Controller/RiderController.php @@ -565,6 +565,8 @@ class RiderController extends Controller public function riderActiveJO(EntityManagerInterface $em, MQTTClient $mclient, Rider $rider, $jo_id) { $jo = $em->getRepository(JobOrder::class)->find($jo_id); + // TODO: change this to setCurrentJobOrder since this is what is being used to set rider's + // job order. It is no longer using setActiveJobOrder. $rider->setActiveJobOrder($jo); $em->flush(); From 05d50e28f7bc0466ce98393e58e2cdbbc3bcebc0 Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Mon, 8 Nov 2021 07:45:31 +0000 Subject: [PATCH 10/11] Comment out debug log. #630 --- src/Command/UpdateUnacceptedJobOrdersCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Command/UpdateUnacceptedJobOrdersCommand.php b/src/Command/UpdateUnacceptedJobOrdersCommand.php index b23eb215..2a9ba2c6 100644 --- a/src/Command/UpdateUnacceptedJobOrdersCommand.php +++ b/src/Command/UpdateUnacceptedJobOrdersCommand.php @@ -89,7 +89,7 @@ class UpdateUnacceptedJobOrdersCommand extends Command $jo = $jo_info['jo']; if ($jo != null) { - $output->writeln('Requeuing for rider assignment ' . $jo->getID()); + // $output->writeln('Requeuing for rider assignment ' . $jo->getID()); $id = $jo->getID(); // send notifications to rider app, telling rider that jo has been requeued From 09405d16cef0b001bef1ab39346dfa771605a8f8 Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Mon, 8 Nov 2021 08:23:38 +0000 Subject: [PATCH 11/11] Add setting of date_assign when JO is auto assigned. Add sql script to update date_assign of JOs. #630 --- src/Controller/APIController.php | 3 ++- utils/update_jo_date_assign/update_jo_date_assign.sql | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 utils/update_jo_date_assign/update_jo_date_assign.sql diff --git a/src/Controller/APIController.php b/src/Controller/APIController.php index dd5ec30d..ee2acf7a 100644 --- a/src/Controller/APIController.php +++ b/src/Controller/APIController.php @@ -2957,7 +2957,8 @@ class APIController extends Controller implements LoggedController $jo->setStatusAutoAssign(AutoAssignStatus::HUB_AND_RIDER_ASSIGNED); $jo->setDeliveryStatus(DeliveryStatus::RIDER_ASSIGN); - // TODO: set date_assigned for job order + // set date_assigned for job order + $jo->setDateAssign(new DateTime()); $assigned_rider->setAvailable(false); diff --git a/utils/update_jo_date_assign/update_jo_date_assign.sql b/utils/update_jo_date_assign/update_jo_date_assign.sql new file mode 100644 index 00000000..5c30b3ae --- /dev/null +++ b/utils/update_jo_date_assign/update_jo_date_assign.sql @@ -0,0 +1 @@ +UPDATE job_order SET date_assign = date_create WHERE date_assign is null;