diff --git a/src/Repository/PlaceRepository.php b/src/Repository/PlaceRepository.php index e1de617..58b29b5 100644 --- a/src/Repository/PlaceRepository.php +++ b/src/Repository/PlaceRepository.php @@ -109,7 +109,7 @@ class PlaceRepository // count the places never visited $selectUnvisited = new Select(\Container::$dbConnection, 'places'); $selectUnvisited->leftJoin($selectPlacesByCurrentUser, ['places', 'id'], '=', ['places_by_current_user', 'place_id']); - $selectUnvisited->where('map_id', '=', $mapId); + $selectUnvisited->where(['places', 'map_id'], '=', $mapId); $selectUnvisited->where(['places_by_current_user', 'last_time'], '=', null); $numberOfUnvisitedPlaces = $selectUnvisited->count(); @@ -140,11 +140,11 @@ class PlaceRepository // count places that were visited at least once $selectOldPlaces = new Select(\Container::$dbConnection, 'places'); $selectOldPlaces->innerJoin($selectPlacesByCurrentUser, ['places', 'id'], '=', ['places_by_current_user', 'place_id']); - $selectOldPlaces->where('map_id', '=', $mapId); + $selectOldPlaces->where(['places', 'map_id'], '=', $mapId); $numberOfOldPlaces = $selectOldPlaces->count(); // set order by datetime, oldest first - $selectOldPlaces->orderBy('last_time'); + $selectOldPlaces->orderBy(['places_by_current_user', 'last_time']); // selection algorithm with preference (weighting) for older places using Box-Muller transform $pickGaussianRandomInt = function($numberOfPlaces) {