From 87e12144440b9525cbabdca5a9f79038a9a0f0e0 Mon Sep 17 00:00:00 2001 From: Joris Date: Sat, 12 Feb 2022 17:21:29 +0100 Subject: Show current progress after the deck name --- src/db/db.rs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/db') diff --git a/src/db/db.rs b/src/db/db.rs index 4c2d9a2..590f3ea 100644 --- a/src/db/db.rs +++ b/src/db/db.rs @@ -108,6 +108,15 @@ pub fn next_ready(conn: &Connection) -> Option { }) } +pub fn count_available(conn: &Connection) -> Option { + let now = time::now().ok()?; + let mut stmt = conn.prepare("SELECT COUNT(*) FROM cards WHERE ready <= ? AND deleted IS NULL").ok()?; + + let mut rows = stmt.query([now]).ok()?; + let row = rows.next().ok()??; + row.get(0).ok()? +} + pub fn update(conn: &Connection, question: &String, state: &space_repetition::State) -> Result<()> { let now = time::now()?; let ready = now + state.get_interval_seconds(); -- cgit v1.2.3