From 0db97dd1f3c1a2af5f24e8e1d8d44c84e56c94ba Mon Sep 17 00:00:00 2001 From: Luc Mcgrady Date: Thu, 5 Jun 2025 18:33:45 +0100 Subject: [PATCH] make global --- proto/anki/deck_config.proto | 3 ++- rslib/src/config/bool.rs | 1 + rslib/src/deckconfig/mod.rs | 1 - rslib/src/deckconfig/schema11.rs | 1 - rslib/src/deckconfig/service.rs | 1 + rslib/src/deckconfig/update.rs | 5 +++++ ts/routes/deck-options/FsrsOptions.svelte | 8 +++++--- ts/routes/deck-options/lib.ts | 3 +++ 8 files changed, 17 insertions(+), 6 deletions(-) diff --git a/proto/anki/deck_config.proto b/proto/anki/deck_config.proto index d983f10ea..831283931 100644 --- a/proto/anki/deck_config.proto +++ b/proto/anki/deck_config.proto @@ -193,7 +193,6 @@ message DeckConfig { reserved 39; float historical_retention = 40; string param_search = 45; - bool health_check = 47; bytes other = 255; } @@ -236,6 +235,7 @@ message DeckConfigsForUpdate { // only applies to v3 scheduler bool new_cards_ignore_review_limit = 7; bool fsrs = 8; + bool fsrs_health_check = 11; bool apply_all_parent_limits = 9; uint32 days_since_last_fsrs_optimize = 10; } @@ -259,4 +259,5 @@ message UpdateDeckConfigsRequest { bool fsrs = 8; bool apply_all_parent_limits = 9; bool fsrs_reschedule = 10; + bool fsrs_health_check = 11; } diff --git a/rslib/src/config/bool.rs b/rslib/src/config/bool.rs index b430babe4..ca3603d5e 100644 --- a/rslib/src/config/bool.rs +++ b/rslib/src/config/bool.rs @@ -40,6 +40,7 @@ pub enum BoolKey { WithScheduling, WithDeckConfigs, Fsrs, + FsrsHealthCheck, LoadBalancerEnabled, FsrsShortTermWithStepsEnabled, #[strum(to_string = "normalize_note_text")] diff --git a/rslib/src/deckconfig/mod.rs b/rslib/src/deckconfig/mod.rs index c6ba7f8c6..c522ea18a 100644 --- a/rslib/src/deckconfig/mod.rs +++ b/rslib/src/deckconfig/mod.rs @@ -78,7 +78,6 @@ const DEFAULT_DECK_CONFIG_INNER: DeckConfigInner = DeckConfigInner { fsrs_params_5: vec![], fsrs_params_6: vec![], desired_retention: 0.9, - health_check: false, other: Vec::new(), historical_retention: 0.9, param_search: String::new(), diff --git a/rslib/src/deckconfig/schema11.rs b/rslib/src/deckconfig/schema11.rs index ac5979c1c..2d862a3a0 100644 --- a/rslib/src/deckconfig/schema11.rs +++ b/rslib/src/deckconfig/schema11.rs @@ -400,7 +400,6 @@ impl From for DeckConfig { desired_retention: c.desired_retention, historical_retention: c.sm2_retention, param_search: c.param_search, - health_check: false, other: other_bytes, }, } diff --git a/rslib/src/deckconfig/service.rs b/rslib/src/deckconfig/service.rs index 516132763..d4f3ea782 100644 --- a/rslib/src/deckconfig/service.rs +++ b/rslib/src/deckconfig/service.rs @@ -158,6 +158,7 @@ impl From for UpdateDeckConfi apply_all_parent_limits: c.apply_all_parent_limits, fsrs: c.fsrs, fsrs_reschedule: c.fsrs_reschedule, + fsrs_health_check: c.fsrs_health_check, } } } diff --git a/rslib/src/deckconfig/update.rs b/rslib/src/deckconfig/update.rs index 5a85d92e1..25305e188 100644 --- a/rslib/src/deckconfig/update.rs +++ b/rslib/src/deckconfig/update.rs @@ -41,6 +41,7 @@ pub struct UpdateDeckConfigsRequest { pub apply_all_parent_limits: bool, pub fsrs: bool, pub fsrs_reschedule: bool, + pub fsrs_health_check: bool, } impl Collection { @@ -71,6 +72,7 @@ impl Collection { new_cards_ignore_review_limit: self.get_config_bool(BoolKey::NewCardsIgnoreReviewLimit), apply_all_parent_limits: self.get_config_bool(BoolKey::ApplyAllParentLimits), fsrs: self.get_config_bool(BoolKey::Fsrs), + fsrs_health_check: self.get_config_bool(BoolKey::FsrsHealthCheck), days_since_last_fsrs_optimize, }) } @@ -300,6 +302,7 @@ impl Collection { req.new_cards_ignore_review_limit, )?; self.set_config_bool_inner(BoolKey::ApplyAllParentLimits, req.apply_all_parent_limits)?; + self.set_config_bool_inner(BoolKey::FsrsHealthCheck, req.fsrs_health_check)?; Ok(()) } @@ -453,6 +456,7 @@ mod test { col.set_config_string_inner(StringKey::CardStateCustomizer, "")?; col.set_config_bool_inner(BoolKey::NewCardsIgnoreReviewLimit, false)?; col.set_config_bool_inner(BoolKey::ApplyAllParentLimits, false)?; + col.set_config_bool_inner(BoolKey::FsrsHealthCheck, true)?; // pretend we're in sync let stamps = col.storage.get_collection_timestamps()?; @@ -489,6 +493,7 @@ mod test { apply_all_parent_limits: false, fsrs: false, fsrs_reschedule: false, + fsrs_health_check: true, }; assert!(!col.update_deck_configs(input.clone())?.changes.had_change()); diff --git a/ts/routes/deck-options/FsrsOptions.svelte b/ts/routes/deck-options/FsrsOptions.svelte index 326589633..684c6711b 100644 --- a/ts/routes/deck-options/FsrsOptions.svelte +++ b/ts/routes/deck-options/FsrsOptions.svelte @@ -59,6 +59,8 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html let computingParams = false; let checkingParams = false; + const healthCheck = state.fsrsHealthCheck; + $: computing = computingParams || checkingParams; $: defaultparamSearch = `preset:"${state.getCurrentNameForSearch()}" -is:suspended`; $: roundedRetention = Number($config.desiredRetention.toFixed(2)); @@ -179,7 +181,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html ignoreRevlogsBeforeMs: getIgnoreRevlogsBeforeMs(), currentParams: params, numOfRelearningSteps: numOfRelearningStepsInDay, - healthCheck: $config.healthCheck, + healthCheck: $healthCheck, }); const already_optimal = @@ -333,9 +335,9 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html {/if} - + openHelpModal("deckConfigHealthCheck")}> - {tr.deckConfigHealthCheck()} + diff --git a/ts/routes/deck-options/lib.ts b/ts/routes/deck-options/lib.ts index c9eabb0f7..7e122fac9 100644 --- a/ts/routes/deck-options/lib.ts +++ b/ts/routes/deck-options/lib.ts @@ -62,6 +62,7 @@ export class DeckOptionsState { readonly applyAllParentLimits: Writable; readonly fsrs: Writable; readonly fsrsReschedule: Writable = writable(false); + readonly fsrsHealthCheck: Writable; readonly daysSinceLastOptimization: Writable; readonly currentPresetName: Writable; /** Used to detect if there are any pending changes */ @@ -103,6 +104,7 @@ export class DeckOptionsState { this.newCardsIgnoreReviewLimit = writable(data.newCardsIgnoreReviewLimit); this.applyAllParentLimits = writable(data.applyAllParentLimits); this.fsrs = writable(data.fsrs); + this.fsrsHealthCheck = writable(data.fsrsHealthCheck); this.daysSinceLastOptimization = writable(data.daysSinceLastFsrsOptimize); // decrement the use count of the starting item, as we'll apply +1 to currently @@ -267,6 +269,7 @@ export class DeckOptionsState { applyAllParentLimits: get(this.applyAllParentLimits), fsrs: get(this.fsrs), fsrsReschedule: get(this.fsrsReschedule), + fsrsHealthCheck: get(this.fsrsHealthCheck), }; }