From b02e3f35cdcdb5a1fc2ac5ec5224502e1cc5f32d Mon Sep 17 00:00:00 2001 From: Brutus5000 Date: Sun, 10 Nov 2019 20:00:11 +0100 Subject: [PATCH] Correctly handle expired and revoked bans (fixes #360) --- .../api/leaderboard/GlobalLeaderboardRepository.java | 6 +++--- .../api/leaderboard/Ladder1v1LeaderboardRepository.java | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/faforever/api/leaderboard/GlobalLeaderboardRepository.java b/src/main/java/com/faforever/api/leaderboard/GlobalLeaderboardRepository.java index b00e5951c..0bfabfe24 100644 --- a/src/main/java/com/faforever/api/leaderboard/GlobalLeaderboardRepository.java +++ b/src/main/java/com/faforever/api/leaderboard/GlobalLeaderboardRepository.java @@ -20,13 +20,13 @@ public interface GlobalLeaderboardRepository extends Repository 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 getLeaderboardByPage(Pageable pageable); @@ -43,7 +43,7 @@ public interface GlobalLeaderboardRepository extends Repository 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); diff --git a/src/main/java/com/faforever/api/leaderboard/Ladder1v1LeaderboardRepository.java b/src/main/java/com/faforever/api/leaderboard/Ladder1v1LeaderboardRepository.java index 641526406..b6ea33710 100644 --- a/src/main/java/com/faforever/api/leaderboard/Ladder1v1LeaderboardRepository.java +++ b/src/main/java/com/faforever/api/leaderboard/Ladder1v1LeaderboardRepository.java @@ -21,13 +21,13 @@ public interface Ladder1v1LeaderboardRepository extends Repository 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) @@ -46,7 +46,7 @@ public interface Ladder1v1LeaderboardRepository extends Repository 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);