Merge pull request 'fix unambiguous where and orderBy statements in PlaceRepository' (!67) from fix-selects-in-placerepository into develop
All checks were successful
mapguesser/pipeline/head This commit looks good

Reviewed-on: #67
This commit is contained in:
Bence Pőcze 2023-09-15 01:40:16 +02:00 committed by Gitea
commit a255180a4d
Signed by: Gitea
GPG Key ID: 7B89B83EED9AD2C6

View File

@ -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) {