Remove checking for rider validity. Add call to RiderTracker service from the APIController. #180
This commit is contained in:
parent
9503089642
commit
e61d77ad8b
2 changed files with 21 additions and 20 deletions
|
|
@ -26,6 +26,7 @@ use App\Service\InvoiceCreator;
|
|||
use App\Service\RisingTideGateway;
|
||||
use App\Service\MQTTClient;
|
||||
use App\Service\GeofenceTracker;
|
||||
use App\Service\RiderTracker;
|
||||
|
||||
use App\Entity\MobileSession;
|
||||
use App\Entity\Customer;
|
||||
|
|
@ -1116,7 +1117,7 @@ class APIController extends Controller
|
|||
return $res->getReturnResponse();
|
||||
}
|
||||
|
||||
public function getRiderStatus(Request $req)
|
||||
public function getRiderStatus(Request $req, RiderTracker $rt)
|
||||
{
|
||||
$required_params = [];
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
|
@ -1243,8 +1244,9 @@ class APIController extends Controller
|
|||
case JOStatus::ASSIGNED:
|
||||
case JOStatus::IN_TRANSIT:
|
||||
case JOStatus::IN_PROGRESS:
|
||||
$coord = $jo->getHub()->getCoordinates();
|
||||
$rider = $jo->getRider();
|
||||
// get rider coordinates from redis
|
||||
$coord = $rt->getRiderLocation($rider->getID());
|
||||
|
||||
// default image url
|
||||
$url_prefix = $req->getSchemeAndHttpHost();
|
||||
|
|
|
|||
|
|
@ -33,26 +33,25 @@ class RiderTracker
|
|||
|
||||
public function getRiderLocation($rider_id)
|
||||
{
|
||||
// check if rider id exists or is valid
|
||||
$rider = $this->em->getRepository(Rider::class)->find($rider_id);
|
||||
if ($rider != null)
|
||||
$coordinates = new Point(0,0);
|
||||
$key = $this->getRiderKey($rider_id);
|
||||
|
||||
// check redis cache for rider information
|
||||
if (($this->redis->hexists($key, 'longitude')) &&
|
||||
($this->redis->hexists($key, 'latitude')))
|
||||
{
|
||||
$coordinates = $rider->getHub()->getCoordinates();
|
||||
|
||||
$key = $this->getRiderKey($rider_id);
|
||||
|
||||
// check redis cache for rider information
|
||||
if (($this->redis->hexists($key, 'longitude')) &&
|
||||
($this->redis->hexists($key, 'latitude')))
|
||||
{
|
||||
$long = $this->redis->hget($key, 'longitude');
|
||||
$lat = $this->redis->hget($key, 'latitude');
|
||||
|
||||
$coordinates = new Point($long, $lat);
|
||||
}
|
||||
|
||||
return $coordinates;
|
||||
$long = $this->redis->hget($key, 'longitude');
|
||||
$lat = $this->redis->hget($key, 'latitude');
|
||||
|
||||
$coordinates = new Point($long, $lat);
|
||||
}
|
||||
else
|
||||
{
|
||||
$rider = $this->em->getRepository(Rider::class)->find($rider_id);
|
||||
$coordinates = $rider->getHub()->getCoordinates();
|
||||
}
|
||||
|
||||
return $coordinates;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue