Fix dashboard map bug when rider has no assigned hub #270

This commit is contained in:
Kendrick Chan 2019-12-16 20:25:15 +08:00
parent 494ae85467
commit 2f3e8df6d4

View file

@ -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();
}
}