From 74077dff17a38d729f68ccc60e3aa9be250f57d0 Mon Sep 17 00:00:00 2001 From: user1823 <92206575+user1823@users.noreply.github.com> Date: Mon, 13 Jan 2025 21:26:06 +0530 Subject: [PATCH] Fix entries not being removed if ignore_before_date after the last grade --- rslib/src/scheduler/fsrs/params.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/rslib/src/scheduler/fsrs/params.rs b/rslib/src/scheduler/fsrs/params.rs index a5b916746a..68ae5eff75 100644 --- a/rslib/src/scheduler/fsrs/params.rs +++ b/rslib/src/scheduler/fsrs/params.rs @@ -340,6 +340,9 @@ pub(crate) fn reviews_for_fsrs( if idx > 0 { entries.drain(..idx); } + } else { + // if no valid user grades were found, drain all entries + entries.drain(..); } // Filter out unwanted entries @@ -709,4 +712,19 @@ pub(crate) mod tests { 2 ); } + + #[test] + fn ignore_before_after_last_revlog_entry() { + let revlogs = &[ + revlog(RevlogReviewKind::Learning, 10), + revlog(RevlogReviewKind::Review, 6), + ]; + // L R | + assert_eq!( + convert_ignore_before(revlogs, false, days_ago_ms(4)) + .unwrap() + .len(), + 0 + ); + } }