Fix for the leaderboard query not showing enough people below you when you are first, second or third place

This commit is contained in:
Vari
2025-12-14 20:42:16 +01:00
parent 9a2086e09b
commit b2d87f7c8b

View File

@@ -109,8 +109,7 @@ public static function getLeaderboardEntriesForPlayer(string|array $userId, Fact
$mainQuery->where('rank', '<=', function (\Illuminate\Database\Query\Builder $whereQuery) use ($userId, $query) {
$whereQuery->where('user_id', $userId);
$whereQuery->fromSub($query, 'c');
$whereQuery->selectRaw('(c.rank + 1)');
$whereQuery->selectRaw('(c.rank + (CASE c.rank WHEN 1 THEN 4 WHEN 2 THEN 3 WHEN 3 THEN 2 ELSE 1 END))');
});
}
$mainQuery->orderByDesc('rank');