From bd91d22aac5135980f2cf11dbf0510ee927252e6 Mon Sep 17 00:00:00 2001 From: Jarrett Ye Date: Thu, 31 Jul 2025 18:11:22 +0800 Subject: [PATCH] Add is_reset method to RevlogEntry and update scheduling logic This commit introduces the `is_reset` method to the `RevlogEntry` struct, which identifies entries representing reset operations. Additionally, the scheduling logic in `memory_state.rs` and `params.rs` has been updated to utilize this new method, ensuring that reset entries are handled correctly during review scheduling. --- rslib/src/revlog/mod.rs | 7 +++++++ rslib/src/scheduler/fsrs/memory_state.rs | 2 ++ rslib/src/scheduler/fsrs/params.rs | 5 +---- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/rslib/src/revlog/mod.rs b/rslib/src/revlog/mod.rs index 2155bfcdc..2cd734b0a 100644 --- a/rslib/src/revlog/mod.rs +++ b/rslib/src/revlog/mod.rs @@ -85,6 +85,13 @@ impl RevlogEntry { .unwrap() } + /// Returns true if this entry represents a reset operation. + /// These entries are created when a card is reset using + /// [`Collection::reschedule_cards_as_new`]. + pub(crate) fn is_reset(&self) -> bool { + self.review_kind == RevlogReviewKind::Manual && self.ease_factor == 0 + } + /// Returns true if the review entry is not manually rescheduled and not /// cramming. Used to filter out entries that shouldn't be considered /// for statistics and scheduling. diff --git a/rslib/src/scheduler/fsrs/memory_state.rs b/rslib/src/scheduler/fsrs/memory_state.rs index 28b8fd636..062f5bcca 100644 --- a/rslib/src/scheduler/fsrs/memory_state.rs +++ b/rslib/src/scheduler/fsrs/memory_state.rs @@ -325,6 +325,8 @@ pub(crate) fn get_last_revlog_info(revlogs: &[RevlogEntry]) -> HashMap