diff --git a/src/Service/RiderTracker.php b/src/Service/RiderTracker.php index 1e377ec7..905171e4 100644 --- a/src/Service/RiderTracker.php +++ b/src/Service/RiderTracker.php @@ -38,15 +38,18 @@ class RiderTracker $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 new Point($long, $lat); } - return $coordinates; + // not in cache, get hub + $rider = $this->em->getRepository(Rider::class)->find($rider_id); + $hub = $rider->getHub(); + // no hub + // TODO: return valid coordinate + if ($hub == null) + return new Point(0, 0); + + return $hub->getCoordinates(); } }