Skip to content

Commit

Permalink
Use generated rating column for leaderboard queries (followup of #331)
Browse files Browse the repository at this point in the history
  • Loading branch information
Brutus5000 committed Aug 25, 2019
1 parent 355a8b0 commit d820ea2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public interface GlobalLeaderboardRepository extends Repository<GlobalLeaderboar
" SELECT player_id FROM ban" +
" WHERE (expires_at is null or expires_at > NOW()) AND (revoke_time IS NULL OR revoke_time > NOW())" +
" ) " +
" ORDER BY round(mean - 3 * deviation) DESC LIMIT ?#{#pageable.offset},?#{#pageable.pageSize}",
" 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" +
Expand All @@ -44,6 +44,6 @@ public interface GlobalLeaderboardRepository extends Repository<GlobalLeaderboar
" SELECT player_id FROM ban" +
" WHERE (expires_at is null or expires_at <= NOW()) AND (revoke_time IS NULL OR revoke_time > NOW())" +
" ) " +
"ORDER BY round(mean - 3 * deviation) DESC) as leaderboard WHERE id = :playerId", nativeQuery = true)
"ORDER BY rating DESC) as leaderboard WHERE id = :playerId", nativeQuery = true)
GlobalLeaderboardEntry findByPlayerId(@Param("playerId") int playerId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public interface Ladder1v1LeaderboardRepository extends Repository<Ladder1v1Lead
" SELECT player_id FROM ban" +
" WHERE (expires_at is null or expires_at > NOW()) AND (revoke_time IS NULL OR revoke_time > NOW())" +
" ) " +
" ORDER BY round(mean - 3 * deviation) DESC LIMIT ?#{#pageable.offset},?#{#pageable.pageSize}",
" 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" +
Expand All @@ -47,6 +47,6 @@ public interface Ladder1v1LeaderboardRepository extends Repository<Ladder1v1Lead
" SELECT player_id FROM ban" +
" WHERE (expires_at is null or expires_at > NOW()) AND (revoke_time IS NULL OR revoke_time > NOW())" +
" ) " +
"ORDER BY round(mean - 3 * deviation) DESC) as leaderboard WHERE id = :playerId", nativeQuery = true)
"ORDER BY rating DESC) as leaderboard WHERE id = :playerId", nativeQuery = true)
Ladder1v1LeaderboardEntry findByPlayerId(@Param("playerId") int playerId);
}

0 comments on commit d820ea2

Please sign in to comment.