mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
Support retrievability calculation for (re)learning cards
This commit is contained in:
parent
da0e42ea03
commit
bb0acd9d92
2 changed files with 22 additions and 17 deletions
|
@ -121,6 +121,9 @@ impl Card {
|
|||
}
|
||||
|
||||
pub(crate) fn days_since_last_review(&self, timing: &SchedTimingToday) -> Option<u32> {
|
||||
if !self.is_due_in_days() {
|
||||
Some(0)
|
||||
} else {
|
||||
self.due_time(timing).map(|due| {
|
||||
due.adding_secs(-86_400 * self.interval as i64)
|
||||
.elapsed_secs()
|
||||
|
@ -129,6 +132,7 @@ impl Card {
|
|||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Note {
|
||||
fn is_marked(&self) -> bool {
|
||||
|
|
|
@ -285,10 +285,10 @@ fn add_extract_fsrs_retrievability(db: &Connection) -> rusqlite::Result<()> {
|
|||
let Ok(due) = ctx.get_raw(1).as_i64() else {
|
||||
return Ok(None);
|
||||
};
|
||||
if due > 365_000 {
|
||||
// learning card
|
||||
return Ok(None);
|
||||
}
|
||||
let days_elapsed = if due > 365_000 {
|
||||
// (re)learning card, assume 0 days have elapsed
|
||||
0
|
||||
} else {
|
||||
let Ok(ivl) = ctx.get_raw(2).as_i64() else {
|
||||
return Ok(None);
|
||||
};
|
||||
|
@ -296,7 +296,8 @@ fn add_extract_fsrs_retrievability(db: &Connection) -> rusqlite::Result<()> {
|
|||
return Ok(None);
|
||||
};
|
||||
let review_day = (due.max(0) as u32).saturating_sub(ivl as u32);
|
||||
let days_elapsed = (days_elapsed.max(0) as u32).saturating_sub(review_day);
|
||||
(days_elapsed.max(0) as u32).saturating_sub(review_day)
|
||||
};
|
||||
Ok(card_data.memory_state().map(|state| {
|
||||
FSRS::new(None)
|
||||
.unwrap()
|
||||
|
|
Loading…
Reference in a new issue