From 6874440cdad97185c13cb37f717bcd787fe2c445 Mon Sep 17 00:00:00 2001 From: Jarrett Ye Date: Tue, 26 Nov 2024 12:23:19 +0800 Subject: [PATCH] Fix/incorrect memory state inference for incomplete review history (#3599) make ci happy --- rslib/src/scheduler/fsrs/memory_state.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/rslib/src/scheduler/fsrs/memory_state.rs b/rslib/src/scheduler/fsrs/memory_state.rs index decc9777b4..4f1ea90c86 100644 --- a/rslib/src/scheduler/fsrs/memory_state.rs +++ b/rslib/src/scheduler/fsrs/memory_state.rs @@ -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 { @@ -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)