Skip to content

Commit b02e3f3

Browse files
committed
Correctly handle expired and revoked bans (fixes #360)
1 parent 1f1327f commit b02e3f3

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/main/java/com/faforever/api/leaderboard/GlobalLeaderboardRepository.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ public interface GlobalLeaderboardRepository extends Repository<GlobalLeaderboar
2020
" WHERE is_active = 1" +
2121
" AND login.id NOT IN (" +
2222
" SELECT player_id FROM ban" +
23-
" WHERE (expires_at is null or expires_at > NOW()) AND (revoke_time IS NULL OR revoke_time > NOW())" +
23+
" WHERE (expires_at is null or expires_at > NOW()) AND revoke_time IS NULL" +
2424
" ) " +
2525
" ORDER BY rating DESC LIMIT ?#{#pageable.offset},?#{#pageable.pageSize}",
2626
countQuery = "SELECT count(*) FROM ladder1v1_rating WHERE is_active = 1 AND ladder1v1_rating.numGames > 0" +
2727
" AND id NOT IN (" +
2828
" SELECT player_id FROM ban" +
29-
" WHERE (expires_at is null or expires_at > NOW()) AND (revoke_time IS NULL OR revoke_time > NOW())" +
29+
" WHERE (expires_at is null or expires_at > NOW()) AND revoke_time IS NULL" +
3030
" AND (1=1 OR -1 IN (?,?,?))" +
3131
" ) -- Dummy placeholder for pageable, prevents 'Unknown parameter position': ?,?,?", nativeQuery = true)
3232
Page<GlobalLeaderboardEntry> getLeaderboardByPage(Pageable pageable);
@@ -43,7 +43,7 @@ public interface GlobalLeaderboardRepository extends Repository<GlobalLeaderboar
4343
"WHERE is_active = 1\n" +
4444
" AND login.id NOT IN (" +
4545
" SELECT player_id FROM ban" +
46-
" WHERE (expires_at is null or expires_at <= NOW()) AND (revoke_time IS NULL OR revoke_time > NOW())" +
46+
" WHERE (expires_at is null or expires_at > NOW()) AND revoke_time IS NULL" +
4747
" ) " +
4848
"ORDER BY rating DESC) as leaderboard WHERE id = :playerId", nativeQuery = true)
4949
GlobalLeaderboardEntry findByPlayerId(@Param("playerId") int playerId);

src/main/java/com/faforever/api/leaderboard/Ladder1v1LeaderboardRepository.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ public interface Ladder1v1LeaderboardRepository extends Repository<Ladder1v1Lead
2121
" WHERE is_active = 1 AND ladder1v1_rating.numGames > 0" +
2222
" AND login.id NOT IN (" +
2323
" SELECT player_id FROM ban" +
24-
" WHERE (expires_at is null or expires_at > NOW()) AND (revoke_time IS NULL OR revoke_time > NOW())" +
24+
" WHERE (expires_at is null or expires_at > NOW()) AND revoke_time IS NULL" +
2525
" ) " +
2626
" ORDER BY rating DESC LIMIT ?#{#pageable.offset},?#{#pageable.pageSize}",
2727
countQuery = "SELECT count(*) FROM ladder1v1_rating WHERE is_active = 1 AND ladder1v1_rating.numGames > 0" +
2828
" AND id NOT IN (" +
2929
" SELECT player_id FROM ban" +
30-
" WHERE (expires_at is null or expires_at > NOW()) AND (revoke_time IS NULL OR revoke_time > NOW())" +
30+
" WHERE (expires_at is null or expires_at > NOW()) AND revoke_time IS NULL" +
3131
" AND (1=1 OR -1 IN (?,?,?))" +
3232
" ) -- Dummy placeholder for pageable, prevents 'Unknown parameter position': ?,?,?",
3333
nativeQuery = true)
@@ -46,7 +46,7 @@ public interface Ladder1v1LeaderboardRepository extends Repository<Ladder1v1Lead
4646
"WHERE is_active = 1\n" +
4747
" AND login.id NOT IN (" +
4848
" SELECT player_id FROM ban" +
49-
" WHERE (expires_at is null or expires_at > NOW()) AND (revoke_time IS NULL OR revoke_time > NOW())" +
49+
" WHERE (expires_at is null or expires_at > NOW()) AND revoke_time IS NULL" +
5050
" ) " +
5151
"ORDER BY rating DESC) as leaderboard WHERE id = :playerId", nativeQuery = true)
5252
Ladder1v1LeaderboardEntry findByPlayerId(@Param("playerId") int playerId);

0 commit comments

Comments
 (0)