Paginate the leaderboard from materialized player ratings
CI / Build and push docker image (push) Successful in 1m19s
CI / Build and push docker image (push) Successful in 1m19s
Store each player's leaderboard totals (wins, accumulated points and the latest display name) on player_rating alongside the Elo rating, updated in the same transaction as the match, so the board is a single indexed table query instead of aggregating every participation on each request. GET /api/leaderboard is now page-number paginated (page/limit) and returns the page, page count and total, plus the caller's own rank and page when authenticated; focus=me returns the caller's page directly. The migration adds the columns, backfills them from the match history (inserting rows for players from pre-Elo matches at the initial rating) and replaces the index. backfill_elo rebuilds the aggregates too. The web page opens on the page containing the signed-in player, marks their row and adds a numbered footer pager.
This commit is contained in:
@@ -190,7 +190,12 @@ class ScopaWebSocketTest(unittest.TestCase):
|
||||
self.assertEqual(1, game["last_move"]["seat"])
|
||||
self.assertEqual(card, game["last_move"]["card"])
|
||||
if options:
|
||||
self.assertEqual(2, game["players"][1]["captured_count"])
|
||||
# The pile grows by the captured table cards
|
||||
# plus the card just played.
|
||||
self.assertEqual(
|
||||
len(options[0]) + 1,
|
||||
game["players"][1]["captured_count"],
|
||||
)
|
||||
else:
|
||||
self.assertEqual(5, len(game["table"]))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user