From 56d8402f89654e84ff743293c81e6963809dcfbf Mon Sep 17 00:00:00 2001 From: RumovZ Date: Fri, 22 Oct 2021 12:58:06 +0200 Subject: [PATCH] Fix underflow of learning count (#1444) `counts.learning` includes interday learning cards, so it is not suitable to determine how many cards from the (intraday!) learning queue are already included in the learning count when updating it. --- rslib/src/scheduler/queue/learning.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/rslib/src/scheduler/queue/learning.rs b/rslib/src/scheduler/queue/learning.rs index 773c37cf2..f1d6fbab3 100644 --- a/rslib/src/scheduler/queue/learning.rs +++ b/rslib/src/scheduler/queue/learning.rs @@ -40,13 +40,14 @@ impl CardQueues { learning_count: self.counts.learning, learning_cutoff: self.current_learning_cutoff, }; + let last_ahead_cutoff = self.current_learn_ahead_cutoff(); self.current_learning_cutoff = TimestampSecs::now(); - let ahead_cutoff = self.current_learn_ahead_cutoff(); + let new_ahead_cutoff = self.current_learn_ahead_cutoff(); let new_learning_cards = self .intraday_learning .iter() - .skip(self.counts.learning) - .take_while(|e| e.due <= ahead_cutoff) + .skip_while(|e| e.due <= last_ahead_cutoff) + .take_while(|e| e.due <= new_ahead_cutoff) .count(); self.counts.learning += new_learning_cards;