mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 22:42:25 -04:00
Implement is_cramming method in RevlogEntry and update scheduling logic
This commit adds the `is_cramming` method to the `RevlogEntry` struct, which identifies entries representing cramming operations. The scheduling logic in `params.rs` has been updated to utilize this new method, improving the clarity and maintainability of the code.
This commit is contained in:
parent
bd91d22aac
commit
c5eaeaa91e
2 changed files with 13 additions and 3 deletions
|
@ -92,6 +92,16 @@ impl RevlogEntry {
|
|||
self.review_kind == RevlogReviewKind::Manual && self.ease_factor == 0
|
||||
}
|
||||
|
||||
/// Returns true if this entry represents a cramming operation.
|
||||
/// These entries are created when a card is previewed using
|
||||
/// [`crate::scheduler::answering::CardStateUpdater::apply_preview_state`].
|
||||
/// The `ease_factor` should be 0 because
|
||||
/// [`crate::scheduler::states::ReviewState::revlog_kind`] returns
|
||||
/// `RevlogReviewKind::Filtered` when `days_late() < 0`.
|
||||
pub(crate) fn is_cramming(&self) -> bool {
|
||||
self.review_kind == RevlogReviewKind::Filtered && 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.
|
||||
|
@ -99,7 +109,7 @@ impl RevlogEntry {
|
|||
// not rescheduled/set due date/reset
|
||||
self.button_chosen > 0
|
||||
// not cramming
|
||||
&& (self.review_kind != RevlogReviewKind::Filtered || self.ease_factor != 0)
|
||||
&& !self.is_cramming()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -394,7 +394,7 @@ pub(crate) fn reviews_for_fsrs(
|
|||
let mut revlogs_complete = false;
|
||||
// Working backwards from the latest review...
|
||||
for (index, entry) in entries.iter().enumerate().rev() {
|
||||
if entry.review_kind == RevlogReviewKind::Filtered && entry.ease_factor == 0 {
|
||||
if entry.is_cramming() {
|
||||
continue;
|
||||
}
|
||||
// For incomplete review histories, initial memory state is based on the first
|
||||
|
@ -474,7 +474,7 @@ pub(crate) fn reviews_for_fsrs(
|
|||
// set due date, reset or rescheduled
|
||||
(entry.review_kind == RevlogReviewKind::Manual || entry.button_chosen == 0)
|
||||
|| // cram
|
||||
(entry.review_kind == RevlogReviewKind::Filtered && entry.ease_factor == 0)
|
||||
entry.is_cramming()
|
||||
|| // rescheduled
|
||||
(entry.review_kind == RevlogReviewKind::Rescheduled)
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue