When calculating retrievability, use stability instead of fuzzed interval
This commit is contained in:
parent
9cc4720efe
commit
907a73eb88
|
@ -377,7 +377,7 @@ fn card_order_from_sort_column(column: Column, timing: SchedTimingToday) -> Cow<
|
|||
Column::Stability => "extract_fsrs_variable(c.data, 's') desc".into(),
|
||||
Column::Difficulty => "extract_fsrs_variable(c.data, 'd') desc".into(),
|
||||
Column::Retrievability => format!(
|
||||
"extract_fsrs_retrievability(c.data, c.due, c.ivl, {})",
|
||||
"extract_fsrs_retrievability(c.data, c.due, {})",
|
||||
timing.days_elapsed
|
||||
)
|
||||
.into(),
|
||||
|
|
|
@ -383,7 +383,7 @@ impl SqlWriter<'_> {
|
|||
let elap = self.col.timing_today()?.days_elapsed;
|
||||
write!(
|
||||
self.sql,
|
||||
"extract_fsrs_retrievability(c.data, c.due, c.ivl, {elap}) {op} {r}"
|
||||
"extract_fsrs_retrievability(c.data, c.due, {elap}) {op} {r}"
|
||||
)
|
||||
.unwrap()
|
||||
}
|
||||
|
|
|
@ -264,15 +264,15 @@ fn add_extract_fsrs_variable(db: &Connection) -> rusqlite::Result<()> {
|
|||
)
|
||||
}
|
||||
|
||||
/// eg. extract_fsrs_retrievability(card.data, card.due, card.ivl,
|
||||
/// timing.days_elapsed) -> float | null
|
||||
/// eg. extract_fsrs_retrievability(card.data, card.due, timing.days_elapsed) ->
|
||||
/// float | null
|
||||
fn add_extract_fsrs_retrievability(db: &Connection) -> rusqlite::Result<()> {
|
||||
db.create_scalar_function(
|
||||
"extract_fsrs_retrievability",
|
||||
4,
|
||||
3,
|
||||
FunctionFlags::SQLITE_DETERMINISTIC,
|
||||
move |ctx| {
|
||||
assert_eq!(ctx.len(), 4, "called with unexpected number of arguments");
|
||||
assert_eq!(ctx.len(), 3, "called with unexpected number of arguments");
|
||||
|
||||
let Ok(card_data) = ctx.get_raw(0).as_str() else {
|
||||
return Ok(None);
|
||||
|
@ -280,6 +280,7 @@ fn add_extract_fsrs_retrievability(db: &Connection) -> rusqlite::Result<()> {
|
|||
if card_data.is_empty() {
|
||||
return Ok(None);
|
||||
}
|
||||
let card_data = &CardData::from_str(card_data);
|
||||
let Ok(due) = ctx.get_raw(1).as_i64() else {
|
||||
return Ok(None);
|
||||
};
|
||||
|
@ -287,16 +288,15 @@ fn add_extract_fsrs_retrievability(db: &Connection) -> rusqlite::Result<()> {
|
|||
// learning card
|
||||
return Ok(None);
|
||||
}
|
||||
let Ok(ivl) = ctx.get_raw(2).as_i64() else {
|
||||
let Ok(days_elapsed) = ctx.get_raw(2).as_i64() else {
|
||||
return Ok(None);
|
||||
};
|
||||
let Ok(days_elapsed) = ctx.get_raw(3).as_i64() else {
|
||||
let Some(stability) = card_data.fsrs_stability else {
|
||||
return Ok(None);
|
||||
};
|
||||
|
||||
let review_day = due - ivl;
|
||||
let review_day = due.saturating_sub(stability as i64);
|
||||
let days_elapsed = days_elapsed.saturating_sub(review_day) as u32;
|
||||
let card_data = &CardData::from_str(card_data);
|
||||
Ok(card_data.memory_state().map(|state| {
|
||||
FSRS::new(None)
|
||||
.unwrap()
|
||||
|
|
Loading…
Reference in New Issue