Conversation
There was a problem hiding this comment.
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_duefunction to query the number of cards due for review in a deck - Made
--deckargument 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.
| /// 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) | ||
| } |
There was a problem hiding this comment.
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.
No description provided.