Resolve "CMB - rider cannot go offline if rider has assigned JOs" #1326

Merged
korina.cordero merged 3 commits from 437-cmb-rider-cannot-go-offline-if-rider-has-assigned-jos into 424-cmb-release 2020-07-21 07:14:18 +00:00
Showing only changes of commit 109911bbb0 - Show all commits

View file

@ -976,7 +976,7 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
$jo->requeue();
// TODO: do we leave JO as assigned to rider?
$jo->clearRider();
// add event log
$rider = $this->session->getRider();
@ -987,6 +987,9 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
->setRider($rider);
$this->em->persist($event);
// set rider's active JO to null
$rider->setActiveJobOrder();
$this->em->flush();
// send mqtt event
@ -997,6 +1000,13 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
];
$this->mclient->sendEvent($jo, $payload);
// need to send another mqtt event saying rider is available
// to change icon on dashboard
$channel = 'rider/' . $rider->getID() . '/status';
$rider_status = 'available';
$this->mclient->publish($channel, $rider_status);
return $data;
}