mirror of
https://github.com/ankitects/anki.git
synced 2026-01-12 05:23:55 -05:00
Refactor desired retention logic to use a dedicated method for improved clarity and maintainability.
This commit is contained in:
parent
2b130ff98c
commit
5f09b227ca
3 changed files with 13 additions and 13 deletions
|
|
@ -31,6 +31,7 @@ pub(crate) use name::immediate_parent_name;
|
|||
pub use name::NativeDeckName;
|
||||
pub use schema11::DeckSchema11;
|
||||
|
||||
use crate::deckconfig::DeckConfig;
|
||||
use crate::define_newtype;
|
||||
use crate::error::FilteredDeckError;
|
||||
use crate::markdown::render_markdown;
|
||||
|
|
@ -89,6 +90,16 @@ impl Deck {
|
|||
}
|
||||
}
|
||||
|
||||
/// Get the effective desired retention value for a deck.
|
||||
/// Returns deck-specific desired retention if available, otherwise falls
|
||||
/// back to config default.
|
||||
pub fn effective_desired_retention(&self, config: &DeckConfig) -> f32 {
|
||||
self.normal()
|
||||
.ok()
|
||||
.and_then(|d| d.desired_retention)
|
||||
.unwrap_or(config.inner.desired_retention)
|
||||
}
|
||||
|
||||
// used by tests at the moment
|
||||
|
||||
#[allow(dead_code)]
|
||||
|
|
|
|||
|
|
@ -445,14 +445,7 @@ impl Collection {
|
|||
.or_not_found(card.deck_id)?;
|
||||
let config = self.home_deck_config(deck.config_id(), card.original_deck_id)?;
|
||||
|
||||
// Get deck-specific desired retention if available, otherwise use config
|
||||
// default
|
||||
let desired_retention = deck
|
||||
.normal()
|
||||
.ok()
|
||||
.and_then(|d| d.desired_retention)
|
||||
.unwrap_or(config.inner.desired_retention);
|
||||
|
||||
let desired_retention = deck.effective_desired_retention(&config);
|
||||
let fsrs_enabled = self.get_config_bool(BoolKey::Fsrs);
|
||||
let fsrs_next_states = if fsrs_enabled {
|
||||
let params = config.fsrs_params();
|
||||
|
|
|
|||
|
|
@ -215,11 +215,7 @@ impl Collection {
|
|||
|
||||
// Get deck-specific desired retention if available, otherwise use config
|
||||
// default
|
||||
let desired_retention = deck
|
||||
.normal()
|
||||
.ok()
|
||||
.and_then(|d| d.desired_retention)
|
||||
.unwrap_or(config.inner.desired_retention);
|
||||
let desired_retention = deck.effective_desired_retention(&config);
|
||||
|
||||
let historical_retention = config.inner.historical_retention;
|
||||
let params = config.fsrs_params();
|
||||
|
|
|
|||
Loading…
Reference in a new issue