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\RisingTideGateway;
|
||||||
use App\Service\MQTTClient;
|
use App\Service\MQTTClient;
|
||||||
use App\Service\GeofenceTracker;
|
use App\Service\GeofenceTracker;
|
||||||
|
use App\Service\RiderTracker;
|
||||||
|
|
||||||
use App\Entity\MobileSession;
|
use App\Entity\MobileSession;
|
||||||
use App\Entity\Customer;
|
use App\Entity\Customer;
|
||||||
|
|
@ -1116,7 +1117,7 @@ class APIController extends Controller
|
||||||
return $res->getReturnResponse();
|
return $res->getReturnResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getRiderStatus(Request $req)
|
public function getRiderStatus(Request $req, RiderTracker $rt)
|
||||||
{
|
{
|
||||||
$required_params = [];
|
$required_params = [];
|
||||||
$em = $this->getDoctrine()->getManager();
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
|
@ -1243,8 +1244,9 @@ class APIController extends Controller
|
||||||
case JOStatus::ASSIGNED:
|
case JOStatus::ASSIGNED:
|
||||||
case JOStatus::IN_TRANSIT:
|
case JOStatus::IN_TRANSIT:
|
||||||
case JOStatus::IN_PROGRESS:
|
case JOStatus::IN_PROGRESS:
|
||||||
$coord = $jo->getHub()->getCoordinates();
|
|
||||||
$rider = $jo->getRider();
|
$rider = $jo->getRider();
|
||||||
|
// get rider coordinates from redis
|
||||||
|
$coord = $rt->getRiderLocation($rider->getID());
|
||||||
|
|
||||||
// default image url
|
// default image url
|
||||||
$url_prefix = $req->getSchemeAndHttpHost();
|
$url_prefix = $req->getSchemeAndHttpHost();
|
||||||
|
|
|
||||||
|
|
@ -33,26 +33,25 @@ class RiderTracker
|
||||||
|
|
||||||
public function getRiderLocation($rider_id)
|
public function getRiderLocation($rider_id)
|
||||||
{
|
{
|
||||||
// check if rider id exists or is valid
|
$coordinates = new Point(0,0);
|
||||||
$rider = $this->em->getRepository(Rider::class)->find($rider_id);
|
$key = $this->getRiderKey($rider_id);
|
||||||
if ($rider != null)
|
|
||||||
|
// check redis cache for rider information
|
||||||
|
if (($this->redis->hexists($key, 'longitude')) &&
|
||||||
|
($this->redis->hexists($key, 'latitude')))
|
||||||
{
|
{
|
||||||
$coordinates = $rider->getHub()->getCoordinates();
|
$long = $this->redis->hget($key, 'longitude');
|
||||||
|
$lat = $this->redis->hget($key, 'latitude');
|
||||||
$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;
|
|
||||||
|
|
||||||
|
$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