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.
This commit is contained in:
RumovZ 2021-10-22 12:58:06 +02:00 committed by GitHub
parent d665dbc9a7
commit 56d8402f89
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -40,13 +40,14 @@ impl CardQueues {
learning_count: self.counts.learning, learning_count: self.counts.learning,
learning_cutoff: self.current_learning_cutoff, learning_cutoff: self.current_learning_cutoff,
}; };
let last_ahead_cutoff = self.current_learn_ahead_cutoff();
self.current_learning_cutoff = TimestampSecs::now(); 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 let new_learning_cards = self
.intraday_learning .intraday_learning
.iter() .iter()
.skip(self.counts.learning) .skip_while(|e| e.due <= last_ahead_cutoff)
.take_while(|e| e.due <= ahead_cutoff) .take_while(|e| e.due <= new_ahead_cutoff)
.count(); .count();
self.counts.learning += new_learning_cards; self.counts.learning += new_learning_cards;