Skip to content

Commit

Permalink
Fix leaderboard count query
Browse files Browse the repository at this point in the history
  • Loading branch information
micheljung committed Aug 10, 2018
1 parent 2e3e05b commit d9f737d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,12 @@ public interface GlobalLeaderboardRepository extends Repository<GlobalLeaderboar
" WHERE (expires_at is null or expires_at <= NOW()) AND ban_revoke.ban_id IS NULL" +
" ) " +
" ORDER BY round(mean - 3 * deviation) DESC LIMIT ?#{#pageable.offset},?#{#pageable.pageSize}",
countQuery = "SELECT count(*) FROM ladder1v1_rating WHERE is_active = 1 AND ladder1v1_rating.numGames > 0",
nativeQuery = true)
countQuery = "SELECT count(*) FROM ladder1v1_rating WHERE is_active = 1 AND ladder1v1_rating.numGames > 0" +
" AND id NOT IN (" +
" SELECT player_id FROM ban" +
" LEFT JOIN ban_revoke on ban.id = ban_revoke.ban_id" +
" WHERE (expires_at is null or expires_at <= NOW()) AND ban_revoke.ban_id IS NULL" +
" ) -- Dummy placeholder for pageable, prevents 'Unknown parameter position': ?,?,?", nativeQuery = true)
Page<GlobalLeaderboardEntry> getLeaderboardByPage(Pageable pageable);

@Query(value = "SELECT * FROM (SELECT\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ public interface Ladder1v1LeaderboardRepository extends Repository<Ladder1v1Lead
" WHERE (expires_at is null or expires_at > NOW()) AND ban_revoke.ban_id IS NULL" +
" ) " +
" ORDER BY round(mean - 3 * deviation) DESC LIMIT ?#{#pageable.offset},?#{#pageable.pageSize}",
countQuery = "SELECT count(*) FROM ladder1v1_rating WHERE is_active = 1 AND ladder1v1_rating.numGames > 0",
countQuery = "SELECT count(*) FROM ladder1v1_rating WHERE is_active = 1 AND ladder1v1_rating.numGames > 0" +
" AND id NOT IN (" +
" SELECT player_id FROM ban" +
" LEFT JOIN ban_revoke on ban.id = ban_revoke.ban_id" +
" WHERE (expires_at is null or expires_at > NOW()) AND ban_revoke.ban_id IS NULL" +
" ) -- Dummy placeholder for pageable, prevents 'Unknown parameter position': ?,?,?",
nativeQuery = true)
Page<Ladder1v1LeaderboardEntry> getLeaderboardByPage(Pageable pageable);

Expand Down

0 comments on commit d9f737d

Please sign in to comment.