fix unambiguous where and orderBy statements in PlaceRepository
All checks were successful
mapguesser/pipeline/pr-develop This commit looks good

This commit is contained in:
Bence Pőcze 2023-09-15 01:38:26 +02:00
parent ddfea0530d
commit af09da8782
Signed by: bence
GPG Key ID: DC5BD6E95A333E6D

View File

@ -109,7 +109,7 @@ class PlaceRepository
// count the places never visited // count the places never visited
$selectUnvisited = new Select(\Container::$dbConnection, 'places'); $selectUnvisited = new Select(\Container::$dbConnection, 'places');
$selectUnvisited->leftJoin($selectPlacesByCurrentUser, ['places', 'id'], '=', ['places_by_current_user', 'place_id']); $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); $selectUnvisited->where(['places_by_current_user', 'last_time'], '=', null);
$numberOfUnvisitedPlaces = $selectUnvisited->count(); $numberOfUnvisitedPlaces = $selectUnvisited->count();
@ -140,11 +140,11 @@ class PlaceRepository
// count places that were visited at least once // count places that were visited at least once
$selectOldPlaces = new Select(\Container::$dbConnection, 'places'); $selectOldPlaces = new Select(\Container::$dbConnection, 'places');
$selectOldPlaces->innerJoin($selectPlacesByCurrentUser, ['places', 'id'], '=', ['places_by_current_user', 'place_id']); $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(); $numberOfOldPlaces = $selectOldPlaces->count();
// set order by datetime, oldest first // 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 // selection algorithm with preference (weighting) for older places using Box-Muller transform
$pickGaussianRandomInt = function($numberOfPlaces) { $pickGaussianRandomInt = function($numberOfPlaces) {