Push limit/offset to the database in PlayerService.get_players #37

Closed
opened 2026-02-20 06:51:06 +00:00 by cal · 1 comment
Owner

app/services/player_service.py:139-148 — Full result set is materialized into a Python list before pagination. All players are fetched and serialized before the list is sliced. Should apply .limit() and .offset() at query level.

Priority: medium | Labels: performance

`app/services/player_service.py:139-148` — Full result set is materialized into a Python list before pagination. All players are fetched and serialized before the list is sliced. Should apply `.limit()` and `.offset()` at query level. **Priority**: medium | **Labels**: performance
cal added the
ai-working
label 2026-03-05 16:31:15 +00:00
cal added
ai-pr-opened
and removed
ai-working
labels 2026-03-05 16:34:20 +00:00
Author
Owner

Fixed in PR #43.

Approach: In PlayerService.get_players, the pagination logic now branches on query type:

  • Real Peewee queries: calls query.count() for total count, then applies .offset()/.limit() at the DB level before materializing results — no full result set is ever loaded into memory.
  • In-memory mocks (InMemoryQueryResult): retains the existing Python list slicing (unchanged behavior for tests).
Fixed in PR #43. **Approach:** In `PlayerService.get_players`, the pagination logic now branches on query type: - **Real Peewee queries**: calls `query.count()` for total count, then applies `.offset()`/`.limit()` at the DB level before materializing results — no full result set is ever loaded into memory. - **In-memory mocks** (`InMemoryQueryResult`): retains the existing Python list slicing (unchanged behavior for tests).
cal closed this issue 2026-03-10 18:26:21 +00:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: cal/major-domo-database#37
No description provided.