Skip to content

Commit

Permalink
Correctly handle expired and revoked bans (fixes #360)
Browse files Browse the repository at this point in the history
  • Loading branch information
Brutus5000 committed Nov 10, 2019
1 parent 1f1327f commit b02e3f3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ public interface GlobalLeaderboardRepository extends Repository<GlobalLeaderboar
" WHERE is_active = 1" +
" AND login.id NOT IN (" +
" SELECT player_id FROM ban" +
" WHERE (expires_at is null or expires_at > NOW()) AND (revoke_time IS NULL OR revoke_time > NOW())" +
" WHERE (expires_at is null or expires_at > NOW()) AND revoke_time IS NULL" +
" ) " +
" ORDER BY rating DESC LIMIT ?#{#pageable.offset},?#{#pageable.pageSize}",
countQuery = "SELECT count(*) FROM ladder1v1_rating WHERE is_active = 1 AND ladder1v1_rating.numGames > 0" +
" AND id NOT IN (" +
" SELECT player_id FROM ban" +
" WHERE (expires_at is null or expires_at > NOW()) AND (revoke_time IS NULL OR revoke_time > NOW())" +
" WHERE (expires_at is null or expires_at > NOW()) AND revoke_time IS NULL" +
" AND (1=1 OR -1 IN (?,?,?))" +
" ) -- Dummy placeholder for pageable, prevents 'Unknown parameter position': ?,?,?", nativeQuery = true)
Page<GlobalLeaderboardEntry> getLeaderboardByPage(Pageable pageable);
Expand All @@ -43,7 +43,7 @@ public interface GlobalLeaderboardRepository extends Repository<GlobalLeaderboar
"WHERE is_active = 1\n" +
" AND login.id NOT IN (" +
" SELECT player_id FROM ban" +
" WHERE (expires_at is null or expires_at <= NOW()) AND (revoke_time IS NULL OR revoke_time > NOW())" +
" WHERE (expires_at is null or expires_at > NOW()) AND revoke_time IS NULL" +
" ) " +
"ORDER BY rating DESC) as leaderboard WHERE id = :playerId", nativeQuery = true)
GlobalLeaderboardEntry findByPlayerId(@Param("playerId") int playerId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ public interface Ladder1v1LeaderboardRepository extends Repository<Ladder1v1Lead
" WHERE is_active = 1 AND ladder1v1_rating.numGames > 0" +
" AND login.id NOT IN (" +
" SELECT player_id FROM ban" +
" WHERE (expires_at is null or expires_at > NOW()) AND (revoke_time IS NULL OR revoke_time > NOW())" +
" WHERE (expires_at is null or expires_at > NOW()) AND revoke_time IS NULL" +
" ) " +
" ORDER BY rating DESC LIMIT ?#{#pageable.offset},?#{#pageable.pageSize}",
countQuery = "SELECT count(*) FROM ladder1v1_rating WHERE is_active = 1 AND ladder1v1_rating.numGames > 0" +
" AND id NOT IN (" +
" SELECT player_id FROM ban" +
" WHERE (expires_at is null or expires_at > NOW()) AND (revoke_time IS NULL OR revoke_time > NOW())" +
" WHERE (expires_at is null or expires_at > NOW()) AND revoke_time IS NULL" +
" AND (1=1 OR -1 IN (?,?,?))" +
" ) -- Dummy placeholder for pageable, prevents 'Unknown parameter position': ?,?,?",
nativeQuery = true)
Expand All @@ -46,7 +46,7 @@ public interface Ladder1v1LeaderboardRepository extends Repository<Ladder1v1Lead
"WHERE is_active = 1\n" +
" AND login.id NOT IN (" +
" SELECT player_id FROM ban" +
" WHERE (expires_at is null or expires_at > NOW()) AND (revoke_time IS NULL OR revoke_time > NOW())" +
" WHERE (expires_at is null or expires_at > NOW()) AND revoke_time IS NULL" +
" ) " +
"ORDER BY rating DESC) as leaderboard WHERE id = :playerId", nativeQuery = true)
Ladder1v1LeaderboardEntry findByPlayerId(@Param("playerId") int playerId);
Expand Down

0 comments on commit b02e3f3

Please sign in to comment.