aboutsummaryrefslogtreecommitdiff
path: root/src/db
diff options
context:
space:
mode:
authorJoris2022-02-12 17:21:29 +0100
committerJoris2022-02-12 17:21:29 +0100
commit87e12144440b9525cbabdca5a9f79038a9a0f0e0 (patch)
tree8414fe44230448eae35e72ae2904cf93753dd552 /src/db
parent3adf3f9697c4e2beb10e652947046d5fddda2ed4 (diff)
Show current progress after the deck name
Diffstat (limited to 'src/db')
-rw-r--r--src/db/db.rs9
1 files changed, 9 insertions, 0 deletions
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<Card> {
})
}
+pub fn count_available(conn: &Connection) -> Option<i32> {
+ 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();