Due-card query with new/review mixing and daily limits #29

Open
opened 2026-09-26 13:58:37 +00:00 by belvedere · 0 comments
Collaborator

Objective: "What should I study right now?" as one efficient, paginated query.

Files:

  • Create: lib/first_thousand_words/study/queue.ex

Steps:

  1. Reviews first: state in [:learning, :review] and due_at <= now, ordered by due_at.
  2. Then new cards up to daily_new_limit, ordered by concept rank so the most frequent words
    come first.
  3. Respect the count of new cards already introduced today (count from Review joined to cards
    that left :new today) — not from a stored counter.
  4. Keyset-paginate; the app already sets default_page_type: :keyset.

Verify: with a fixture of 50 due and 20 new cards and daily_new_limit = 10, the queue
returns 10 new cards and all due reviews, ordered correctly.

**Objective:** "What should I study right now?" as one efficient, paginated query. **Files:** - Create: `lib/first_thousand_words/study/queue.ex` **Steps:** 1. Reviews first: `state in [:learning, :review]` and `due_at <= now`, ordered by `due_at`. 2. Then new cards up to `daily_new_limit`, ordered by concept `rank` so the most frequent words come first. 3. Respect the count of new cards already introduced today (count from `Review` joined to cards that left `:new` today) — not from a stored counter. 4. Keyset-paginate; the app already sets `default_page_type: :keyset`. **Verify:** with a fixture of 50 due and 20 new cards and `daily_new_limit = 10`, the queue returns 10 new cards and all due reviews, ordered correctly.
Sign in to join this conversation.
No assignees
1 participant
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
nickkeers/first-thousand-words#29
No description provided.