Merge branch '362-cmb-fix-dashboard-status-change' into '270-final-cmb-fixes'
Update rider status when job order status is changed #362 See merge request jankstudio/resq!406
This commit is contained in:
commit
d2a4b95805
1 changed files with 34 additions and 1 deletions
|
|
@ -35,6 +35,7 @@ class JobOrderActiveCacheListener
|
||||||
$this->processActiveJO($jo);
|
$this->processActiveJO($jo);
|
||||||
break;
|
break;
|
||||||
// inactive
|
// inactive
|
||||||
|
// NOTE: should never really get here since it's creation
|
||||||
case JOStatus::CANCELLED:
|
case JOStatus::CANCELLED:
|
||||||
$this->processInactiveJO($jo, 'cancel');
|
$this->processInactiveJO($jo, 'cancel');
|
||||||
break;
|
break;
|
||||||
|
|
@ -84,10 +85,23 @@ class JobOrderActiveCacheListener
|
||||||
$coords = $jo->getCoordinates();
|
$coords = $jo->getCoordinates();
|
||||||
|
|
||||||
// TODO: do we put the key in config?
|
// TODO: do we put the key in config?
|
||||||
|
// send jo location
|
||||||
$this->mqtt->publish(
|
$this->mqtt->publish(
|
||||||
'jo/' . $jo->getID() . '/location',
|
'jo/' . $jo->getID() . '/location',
|
||||||
$coords->getLatitude() . ':' . $coords->getLongitude()
|
$coords->getLatitude() . ':' . $coords->getLongitude()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// TODO: do we still need to send jo status?
|
||||||
|
|
||||||
|
// send rider status
|
||||||
|
$rider = $jo->getRider();
|
||||||
|
if ($rider != null)
|
||||||
|
{
|
||||||
|
$this->mqtt->publish(
|
||||||
|
'rider/' . $rider->getID() . '/status',
|
||||||
|
'jo'
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function processInactiveJO($jo, $status = 'cancel')
|
protected function processInactiveJO($jo, $status = 'cancel')
|
||||||
|
|
@ -96,11 +110,30 @@ class JobOrderActiveCacheListener
|
||||||
// remove from redis cache
|
// remove from redis cache
|
||||||
$this->jo_cache->removeActiveJobOrder($jo);
|
$this->jo_cache->removeActiveJobOrder($jo);
|
||||||
|
|
||||||
// TODO: publich to mqtt
|
// publish to mqtt
|
||||||
|
// send jo status
|
||||||
$this->mqtt->publish(
|
$this->mqtt->publish(
|
||||||
'jo/' . $jo->getID() . '/status',
|
'jo/' . $jo->getID() . '/status',
|
||||||
$status
|
$status
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// send rider status
|
||||||
|
$rider = $jo->getRider();
|
||||||
|
if ($rider != null)
|
||||||
|
{
|
||||||
|
// check if rider has any queued jobs
|
||||||
|
$open_jos = $rider->getOpenJobOrders();
|
||||||
|
if (count($open_jos) > 0)
|
||||||
|
$rider_status = 'jo';
|
||||||
|
else
|
||||||
|
$rider_status = 'available';
|
||||||
|
|
||||||
|
// send status
|
||||||
|
$this->mqtt->publish(
|
||||||
|
'rider/' . $rider->getID() . '/status',
|
||||||
|
$rider_status
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue