-
-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0d5e72d
commit 545d663
Showing
2 changed files
with
62 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -277,32 +277,26 @@ function reactivateUserEventAchievements(User $user, array $userUnlocks): array | |
|
||
function GetAllUserProgress(User $user, int $consoleID): array | ||
{ | ||
/** @var Collection<int, PlayerGame> $playerGames */ | ||
/** @var Collection<int, Game> $games */ | ||
$playerGames = $user->playerGames() | ||
Check failure on line 281 in app/Helpers/database/player-game.php GitHub Actions / PHP Checks (analyse)
|
||
->whereIn('game_id', function ($query) use ($consoleID) { | ||
$query->select('ID') | ||
->from('GameData') | ||
->where('ConsoleID', $consoleID) | ||
->where('achievements_published', '>', 0); | ||
->whereHas('game', function ($query) use ($consoleID) { | ||
$query->where('ConsoleID', $consoleID) | ||
->where('achievements_published', '>', 0); | ||
}) | ||
->get() | ||
->keyBy('game_id'); | ||
|
||
/** @var Collection<int, Game> $games */ | ||
$games = Game::where('ConsoleID', $consoleID) | ||
->where('achievements_published', '>', 0) | ||
->where('achievements_unlocked', '>', 0) | ||
->with(['game' => function ($query) { | ||
$query->select('ID', 'achievements_published'); | ||
}]) | ||
->get(); | ||
|
||
/** @var array<int, array{NumAch: int, Earned: int, HCEarned: int}> $retVal */ | ||
$retVal = []; | ||
foreach ($games as $game) { | ||
foreach ($playerGames as $playerGame) { | ||
/** @var ?PlayerGame $playerGame */ | ||
$playerGame = $playerGames->get($game->id); | ||
|
||
$retVal[$game->id] = [ | ||
'NumAch' => $game->achievements_published, | ||
'Earned' => $playerGame?->achievements_unlocked ?? 0, | ||
'HCEarned' => $playerGame?->achievements_unlocked_hardcore ?? 0, | ||
$retVal[$playerGame->game_id] = [ | ||
'Achievements' => $playerGame->game->achievements_published, | ||
'Unlocked' => $playerGame->achievements_unlocked, | ||
'UnlockedHardcore' => $playerGame->achievements_unlocked_hardcore, | ||
]; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters