diff --git a/rslib/src/scheduler/queue/learning.rs b/rslib/src/scheduler/queue/learning.rs index 0edb61264..773c37cf2 100644 --- a/rslib/src/scheduler/queue/learning.rs +++ b/rslib/src/scheduler/queue/learning.rs @@ -94,22 +94,14 @@ impl CardQueues { mut entry: LearningQueueEntry, ) -> LearningQueueEntry { let cutoff = self.current_learn_ahead_cutoff(); + + // if the provided entry would be shown again immediately, see if we + // can place it after the next card instead if entry.due <= cutoff && self.learning_collapsed() { if let Some(next) = self.intraday_learning.front() { - // ensure the card is scheduled after the next due card - if next.due >= entry.due { - if next.due < cutoff { - entry.due = next.due.adding_secs(1) - } else { - // or outside the cutoff, in cases where the next due - // card is due later than the cutoff - entry.due = cutoff.adding_secs(60); - } + if next.due >= entry.due && next.due.adding_secs(1) < cutoff { + entry.due = next.due.adding_secs(1); } - } else { - // nothing else waiting to review; make this due a minute after - // cutoff - entry.due = cutoff.adding_secs(60); } } @@ -164,9 +156,7 @@ impl CardQueues { .current_learning_cutoff .adding_secs(self.learn_ahead_secs) { - // The saturating_sub() deals with a corner case: one remaining - // learning card, delayed so it doesn't appear twice. Will be - // within the current cutoff but not included in the count. + // Theoretically this should never go below zero. self.counts.learning = self.counts.learning.saturating_sub(1); } Some(entry) diff --git a/rslib/src/scheduler/queue/main.rs b/rslib/src/scheduler/queue/main.rs index ae48a4c36..6dc35f000 100644 --- a/rslib/src/scheduler/queue/main.rs +++ b/rslib/src/scheduler/queue/main.rs @@ -25,7 +25,12 @@ impl CardQueues { match head.kind { MainQueueEntryKind::New => self.counts.new -= 1, MainQueueEntryKind::Review => self.counts.review -= 1, - MainQueueEntryKind::InterdayLearning => self.counts.learning -= 1, + MainQueueEntryKind::InterdayLearning => { + // the bug causing learning counts to go below zero should + // hopefully be fixed at this point, but ensure we don't wrap + // if it isn't + self.counts.learning = self.counts.learning.saturating_sub(1) + } }; head })