Skip to content

Commit

Permalink
Fix/incorrect memory state inference for incomplete review history (#…
Browse files Browse the repository at this point in the history
…3599)

make ci happy
  • Loading branch information
L-M-Sherlock authored and dae committed Nov 26, 2024
1 parent 67e7bf1 commit 6874440
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions rslib/src/scheduler/fsrs/memory_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,8 @@ pub(crate) fn single_card_revlog_to_item(
}
let first_review = entries
.iter()
.find(|e| e.button_chosen > 0)
// ignore manual and rescheduled revlogs and revlogs before the cutoff
.find(|e| e.button_chosen > 0 && e.id.0 >= ignore_revlogs_before.0)
.map(|e| FirstReview {
interval: e.interval.max(1) as f32,
ease_factor: if e.ease_factor == 0 {
Expand All @@ -307,11 +308,15 @@ pub(crate) fn single_card_revlog_to_item(
}))
} else if let Some(first_review) = first_review {
// the revlog has been truncated, but not fully
let starting_state = fsrs.memory_state_from_sm2(
let mut starting_state = fsrs.memory_state_from_sm2(
first_review.ease_factor,
first_review.interval,
historical_retention,
)?;
// if the ease factor is less than 1.1, the revlog entry is generated by FSRS
if first_review.ease_factor <= 1.1 {
starting_state.difficulty = (first_review.ease_factor - 0.1) * 9.0 + 1.0;
}
item.reviews.remove(0);
if item.reviews.is_empty() {
Ok(None)
Expand Down

0 comments on commit 6874440

Please sign in to comment.