Merge branch '403-resq-refactor-setting-of-each-day-in-auto-assign-advance-order-jo' into 'master'
Fix getClosestOpenHubs bug #403 Closes #403 See merge request jankstudio/resq!459
This commit is contained in:
commit
13f928a9f3
1 changed files with 7 additions and 3 deletions
|
|
@ -158,13 +158,17 @@ class MapTools
|
|||
public function getClosestOpenHubs(Point $point, $limit, $time = false)
|
||||
{
|
||||
// get closest hubs based on st_distance function from db
|
||||
$query = $this->em->createQuery('SELECT h, st_distance(h.coordinates, point(:lng, :lat)) as dist FROM App\Entity\Hub h' . ($time ? ' WHERE h.status_open = true AND :time BETWEEN h.time_open AND h.time_close' : '') . ' ORDER BY dist')
|
||||
$query_string = 'SELECT h, st_distance(h.coordinates, point(:lng, :lat)) as dist FROM App\Entity\Hub h WHERE h.status_open = true';
|
||||
if ($time)
|
||||
$query_string .= ' AND :time BETWEEN h.time_open AND h.time_close';
|
||||
$query_string .= ' ORDER BY dist';
|
||||
|
||||
$query = $this->em->createQuery($query_string)
|
||||
->setParameter('lat', $point->getLatitude())
|
||||
->setParameter('lng', $point->getLongitude());
|
||||
|
||||
if ($time) {
|
||||
if ($time)
|
||||
$query->setParameter('time', $time);
|
||||
}
|
||||
|
||||
$query->setMaxResults($limit);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue