Skip to content

deck picker#4

Merged
unorsk merged 3 commits intomainfrom
deck-picker
Feb 16, 2026
Merged

deck picker#4
unorsk merged 3 commits intomainfrom
deck-picker

Conversation

@unorsk
Copy link
Owner

@unorsk unorsk commented Feb 16, 2026

No description provided.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds an interactive deck picker to the turbo-m-drill binary, allowing users to select a deck from a visual menu when the --deck argument is omitted. The picker displays due card counts and supports keyboard navigation.

Changes:

  • Added count_due function to query the number of cards due for review in a deck
  • Made --deck argument optional in turbo-m-drill, triggering an interactive picker when omitted
  • Implemented terminal-based deck picker with keyboard navigation (arrow keys, j/k, Enter, Esc/q) and due card count display

Reviewed changes

Copilot reviewed 4 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/storage/repo.rs Added count_due function to count cards due for review using SQL query
src/lib.rs Added count_due wrapper method to expose the functionality
src/bin/turbo-m-drill.rs Made deck argument optional, added pick_deck function with crossterm-based UI, integrated deck selection flow
USAGE.md Updated documentation to reflect optional --deck argument and describe interactive picker behavior
Cargo.toml Added crossterm 0.28 dependency for terminal manipulation
Cargo.lock Lock file updates for crossterm and its dependencies

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +214 to +224
/// Count cards that are due for review in a deck (state != New, due <= now).
pub fn count_due(conn: &Connection, deck_name: &str) -> Result<u32, AppError> {
let deck_id = deck_id_by_name(conn, deck_name)?;
let now = Utc::now().to_rfc3339();
let count: u32 = conn.query_row(
"SELECT COUNT(*) FROM cards WHERE deck_id = ?1 AND state != 0 AND due <= ?2",
params![deck_id, now],
|row| row.get(0),
)?;
Ok(count)
}
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new count_due function lacks test coverage. Since similar query functions like fetch_due have comprehensive tests (see lines 375-416), count_due should also be tested. Consider adding tests to verify: 1) it correctly counts cards with state != 0 and due <= now, 2) it excludes new cards (state = 0), 3) it excludes cards with future due dates, and 4) it handles non-existent decks appropriately.

Copilot uses AI. Check for mistakes.
@unorsk unorsk merged commit 42092da into main Feb 16, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants