Skip to content

Commit

Permalink
feat: use pre-aggregated data for unlocks on user lists (#1924)
Browse files Browse the repository at this point in the history
  • Loading branch information
luchaos committed Oct 23, 2023
1 parent 14bc77c commit 2265ac7
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions app/Helpers/database/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,8 @@ function getUserListByPerms(int $sortBy, int $offset, int $count, ?array &$dataO
default => "ua.User ASC ",
};

// TODO slow query (70) when ordering by NumAwarded
$query = "SELECT ua.ID, ua.User, ua.RAPoints, ua.TrueRAPoints, ua.LastLogin,
(SELECT COUNT(*) AS NumAwarded FROM Awarded AS aw WHERE aw.User = ua.User) NumAwarded
ua.achievements_unlocked NumAwarded
FROM UserAccounts AS ua
$whereQuery
ORDER BY $orderBy
Expand Down

0 comments on commit 2265ac7

Please sign in to comment.