From e5170f341bdcb31dd3dc26619d7a03d2fd6da1e7 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Tue, 28 Nov 2023 14:06:49 +1000 Subject: [PATCH] Remove some v3 checks --- rslib/src/decks/stats.rs | 8 ------- rslib/src/decks/tree.rs | 1 - rslib/src/scheduler/answering/mod.rs | 1 - rslib/src/scheduler/filtered/custom_study.rs | 22 ++++++-------------- rslib/src/scheduler/queue/builder/mod.rs | 13 ++++++------ rslib/src/tests.rs | 7 ------- 6 files changed, 12 insertions(+), 40 deletions(-) diff --git a/rslib/src/decks/stats.rs b/rslib/src/decks/stats.rs index ac174b827..250f5722d 100644 --- a/rslib/src/decks/stats.rs +++ b/rslib/src/decks/stats.rs @@ -57,14 +57,6 @@ impl Collection { }; if let Some(mut deck) = self.storage.get_deck(did)? { 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(()) diff --git a/rslib/src/decks/tree.rs b/rslib/src/decks/tree.rs index 28dc5477a..3d59a6d53 100644 --- a/rslib/src/decks/tree.rs +++ b/rslib/src/decks/tree.rs @@ -440,7 +440,6 @@ mod test { } 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 child_deck = create_deck_with_new_limit(&mut col, "Default::child", 4); diff --git a/rslib/src/scheduler/answering/mod.rs b/rslib/src/scheduler/answering/mod.rs index fe00d61ff..76debca62 100644 --- a/rslib/src/scheduler/answering/mod.rs +++ b/rslib/src/scheduler/answering/mod.rs @@ -627,7 +627,6 @@ mod test { let mut note = Note::new(&nt); col.add_note(&mut note, DeckId(1))?; } - col.set_config_bool(BoolKey::Sched2021, true, false)?; let cids = col.search_cards("", SortMode::NoOrder)?; Ok((col, cids)) } diff --git a/rslib/src/scheduler/filtered/custom_study.rs b/rslib/src/scheduler/filtered/custom_study.rs index 975439e5f..b7d6542ff 100644 --- a/rslib/src/scheduler/filtered/custom_study.rs +++ b/rslib/src/scheduler/filtered/custom_study.rs @@ -44,7 +44,6 @@ impl Collection { let subtree = get_deck_in_tree(self.deck_tree(Some(TimestampSecs::now()))?, deck_id) .or_not_found(deck_id)?; - let v3 = self.get_config_bool(BoolKey::Sched2021); let available_new_including_children = sum_deck_tree_node(&subtree, |node| node.new_uncapped); let available_review_including_children = @@ -54,21 +53,12 @@ impl Collection { available_new_in_children, available_review, available_review_in_children, - ) = if v3 { - ( - subtree.new_uncapped, - available_new_including_children - subtree.new_uncapped, - subtree.review_uncapped, - available_review_including_children - subtree.review_uncapped, - ) - } else { - ( - available_new_including_children, - 0, - available_review_including_children, - 0, - ) - }; + ) = ( + subtree.new_uncapped, + available_new_including_children - subtree.new_uncapped, + subtree.review_uncapped, + available_review_including_children - subtree.review_uncapped, + ); // tags let include_tags: HashSet = self.get_config_default( DeckConfigKey::CustomStudyIncludeTags diff --git a/rslib/src/scheduler/queue/builder/mod.rs b/rslib/src/scheduler/queue/builder/mod.rs index 724178c07..11ce8d4ba 100644 --- a/rslib/src/scheduler/queue/builder/mod.rs +++ b/rslib/src/scheduler/queue/builder/mod.rs @@ -340,7 +340,7 @@ mod test { #[test] 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); col.set_deck_review_limit(DeckId(1), 0); assert_eq!(col.queue_as_deck_and_template(DeckId(1)), vec![]); @@ -348,7 +348,7 @@ mod test { #[test] fn new_queue_building() -> Result<()> { - let mut col = Collection::new_v3(); + let mut col = Collection::new(); // parent // ┣━━child━━grandchild @@ -411,7 +411,6 @@ mod test { #[test] fn review_queue_building() -> Result<()> { 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 nt = col.get_notetype_by_name("Basic")?.unwrap(); @@ -464,7 +463,7 @@ mod test { #[test] 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 CardAdder::new().siblings(2).due_dates(["0"]).add(&mut col); // Potentially problematic config: New cards are shown first and would bury @@ -487,7 +486,7 @@ mod test { #[test] 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) .unwrap(); col.update_default_deck_config(|config| { @@ -501,7 +500,7 @@ mod test { #[test] 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| { config.new_per_day = 1; }); @@ -511,7 +510,7 @@ mod test { #[test] fn may_apply_parent_limits() { - let mut col = Collection::new_v3(); + let mut col = Collection::new(); col.set_config_bool(BoolKey::ApplyAllParentLimits, true, false) .unwrap(); col.update_default_deck_config(|config| { diff --git a/rslib/src/tests.rs b/rslib/src/tests.rs index bfc6369e6..5b7b71151 100644 --- a/rslib/src/tests.rs +++ b/rslib/src/tests.rs @@ -48,13 +48,6 @@ impl Collection { 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])]) { let mgr = MediaManager::new(&self.media_folder, &self.media_db).unwrap(); for (name, data) in media {