Remove some v3 checks

This commit is contained in:
Damien Elmes 2023-11-28 14:06:49 +10:00
parent 7252dd56b6
commit e5170f341b
6 changed files with 12 additions and 40 deletions

View File

@ -57,14 +57,6 @@ impl Collection {
}; };
if let Some(mut deck) = self.storage.get_deck(did)? { if let Some(mut deck) = self.storage.get_deck(did)? {
self.update_deck_stats_single(today, usn, &mut deck, mutator)?; self.update_deck_stats_single(today, usn, &mut deck, mutator)?;
if !self.get_config_bool(BoolKey::Sched2021) {
for mut deck in self.storage.parent_decks(&deck)? {
self.update_deck_stats_single(today, usn, &mut deck, mutator)?;
}
for mut deck in self.storage.child_decks(&deck)? {
self.update_deck_stats_single(today, usn, &mut deck, mutator)?;
}
}
} }
Ok(()) Ok(())

View File

@ -440,7 +440,6 @@ mod test {
} }
let mut col = Collection::new(); let mut col = Collection::new();
col.set_config_bool(BoolKey::Sched2021, true, false)?;
let parent_deck = create_deck_with_new_limit(&mut col, "Default", 8); let parent_deck = create_deck_with_new_limit(&mut col, "Default", 8);
let child_deck = create_deck_with_new_limit(&mut col, "Default::child", 4); let child_deck = create_deck_with_new_limit(&mut col, "Default::child", 4);

View File

@ -627,7 +627,6 @@ mod test {
let mut note = Note::new(&nt); let mut note = Note::new(&nt);
col.add_note(&mut note, DeckId(1))?; col.add_note(&mut note, DeckId(1))?;
} }
col.set_config_bool(BoolKey::Sched2021, true, false)?;
let cids = col.search_cards("", SortMode::NoOrder)?; let cids = col.search_cards("", SortMode::NoOrder)?;
Ok((col, cids)) Ok((col, cids))
} }

View File

@ -44,7 +44,6 @@ impl Collection {
let subtree = get_deck_in_tree(self.deck_tree(Some(TimestampSecs::now()))?, deck_id) let subtree = get_deck_in_tree(self.deck_tree(Some(TimestampSecs::now()))?, deck_id)
.or_not_found(deck_id)?; .or_not_found(deck_id)?;
let v3 = self.get_config_bool(BoolKey::Sched2021);
let available_new_including_children = let available_new_including_children =
sum_deck_tree_node(&subtree, |node| node.new_uncapped); sum_deck_tree_node(&subtree, |node| node.new_uncapped);
let available_review_including_children = let available_review_including_children =
@ -54,21 +53,12 @@ impl Collection {
available_new_in_children, available_new_in_children,
available_review, available_review,
available_review_in_children, available_review_in_children,
) = if v3 { ) = (
(
subtree.new_uncapped, subtree.new_uncapped,
available_new_including_children - subtree.new_uncapped, available_new_including_children - subtree.new_uncapped,
subtree.review_uncapped, subtree.review_uncapped,
available_review_including_children - subtree.review_uncapped, available_review_including_children - subtree.review_uncapped,
) );
} else {
(
available_new_including_children,
0,
available_review_including_children,
0,
)
};
// tags // tags
let include_tags: HashSet<String> = self.get_config_default( let include_tags: HashSet<String> = self.get_config_default(
DeckConfigKey::CustomStudyIncludeTags DeckConfigKey::CustomStudyIncludeTags

View File

@ -340,7 +340,7 @@ mod test {
#[test] #[test]
fn should_build_empty_queue_if_limit_is_reached() { fn should_build_empty_queue_if_limit_is_reached() {
let mut col = Collection::new_v3(); let mut col = Collection::new();
CardAdder::new().due_dates(["0"]).add(&mut col); CardAdder::new().due_dates(["0"]).add(&mut col);
col.set_deck_review_limit(DeckId(1), 0); col.set_deck_review_limit(DeckId(1), 0);
assert_eq!(col.queue_as_deck_and_template(DeckId(1)), vec![]); assert_eq!(col.queue_as_deck_and_template(DeckId(1)), vec![]);
@ -348,7 +348,7 @@ mod test {
#[test] #[test]
fn new_queue_building() -> Result<()> { fn new_queue_building() -> Result<()> {
let mut col = Collection::new_v3(); let mut col = Collection::new();
// parent // parent
// ┣━━child━━grandchild // ┣━━child━━grandchild
@ -411,7 +411,6 @@ mod test {
#[test] #[test]
fn review_queue_building() -> Result<()> { fn review_queue_building() -> Result<()> {
let mut col = Collection::new(); let mut col = Collection::new();
col.set_config_bool(BoolKey::Sched2021, true, false)?;
let mut deck = col.get_or_create_normal_deck("Default").unwrap(); let mut deck = col.get_or_create_normal_deck("Default").unwrap();
let nt = col.get_notetype_by_name("Basic")?.unwrap(); let nt = col.get_notetype_by_name("Basic")?.unwrap();
@ -464,7 +463,7 @@ mod test {
#[test] #[test]
fn new_card_potentially_burying_review_card() { fn new_card_potentially_burying_review_card() {
let mut col = Collection::new_v3(); let mut col = Collection::new();
// add one new and one review card // add one new and one review card
CardAdder::new().siblings(2).due_dates(["0"]).add(&mut col); CardAdder::new().siblings(2).due_dates(["0"]).add(&mut col);
// Potentially problematic config: New cards are shown first and would bury // Potentially problematic config: New cards are shown first and would bury
@ -487,7 +486,7 @@ mod test {
#[test] #[test]
fn new_cards_may_ignore_review_limit() { fn new_cards_may_ignore_review_limit() {
let mut col = Collection::new_v3(); let mut col = Collection::new();
col.set_config_bool(BoolKey::NewCardsIgnoreReviewLimit, true, false) col.set_config_bool(BoolKey::NewCardsIgnoreReviewLimit, true, false)
.unwrap(); .unwrap();
col.update_default_deck_config(|config| { col.update_default_deck_config(|config| {
@ -501,7 +500,7 @@ mod test {
#[test] #[test]
fn reviews_dont_affect_new_limit_before_review_limit_is_reached() { fn reviews_dont_affect_new_limit_before_review_limit_is_reached() {
let mut col = Collection::new_v3(); let mut col = Collection::new();
col.update_default_deck_config(|config| { col.update_default_deck_config(|config| {
config.new_per_day = 1; config.new_per_day = 1;
}); });
@ -511,7 +510,7 @@ mod test {
#[test] #[test]
fn may_apply_parent_limits() { fn may_apply_parent_limits() {
let mut col = Collection::new_v3(); let mut col = Collection::new();
col.set_config_bool(BoolKey::ApplyAllParentLimits, true, false) col.set_config_bool(BoolKey::ApplyAllParentLimits, true, false)
.unwrap(); .unwrap();
col.update_default_deck_config(|config| { col.update_default_deck_config(|config| {

View File

@ -48,13 +48,6 @@ impl Collection {
CollectionBuilder::default().build().unwrap() CollectionBuilder::default().build().unwrap()
} }
pub(crate) fn new_v3() -> Collection {
let mut col = Collection::new();
col.set_config_bool(BoolKey::Sched2021, true, false)
.unwrap();
col
}
pub(crate) fn add_media(&self, media: &[(&str, &[u8])]) { pub(crate) fn add_media(&self, media: &[(&str, &[u8])]) {
let mgr = MediaManager::new(&self.media_folder, &self.media_db).unwrap(); let mgr = MediaManager::new(&self.media_folder, &self.media_db).unwrap();
for (name, data) in media { for (name, data) in media {