This commit is contained in:
Jarrett Ye 2025-10-30 01:34:30 +08:00 committed by GitHub
commit fe57e139e2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 18 additions and 2 deletions

View file

@ -57,6 +57,7 @@ message ConfigKey {
LOAD_BALANCER_ENABLED = 26; LOAD_BALANCER_ENABLED = 26;
FSRS_SHORT_TERM_WITH_STEPS_ENABLED = 27; FSRS_SHORT_TERM_WITH_STEPS_ENABLED = 27;
FSRS_LEGACY_EVALUATE = 28; FSRS_LEGACY_EVALUATE = 28;
FSRS = 29;
} }
enum String { enum String {
SET_DUE_BROWSER = 0; SET_DUE_BROWSER = 0;

View file

@ -9,6 +9,7 @@ import tempfile
import time import time
from anki.collection import Collection as aopen from anki.collection import Collection as aopen
from anki.config import Config
# Between 2-4AM, shift the time back so test assumptions hold. # Between 2-4AM, shift the time back so test assumptions hold.
lt = time.localtime() lt = time.localtime()
@ -49,6 +50,8 @@ def getEmptyCol():
(fd, path) = tempfile.mkstemp(suffix=".anki2") (fd, path) = tempfile.mkstemp(suffix=".anki2")
shutil.copy(_emptyCol, path) shutil.copy(_emptyCol, path)
col = aopen(path) col = aopen(path)
# Disable FSRS for legacy scheduler tests
col.set_config_bool(Config.Bool.FSRS, False, undoable=False)
return col return col

View file

@ -10,6 +10,7 @@ from typing import Dict
import pytest import pytest
from anki import hooks from anki import hooks
from anki.config import Config
from anki.consts import * from anki.consts import *
from anki.lang import without_unicode_isolation from anki.lang import without_unicode_isolation
from anki.scheduler import UnburyDeck from anki.scheduler import UnburyDeck
@ -19,6 +20,8 @@ from tests.shared import getEmptyCol as getEmptyColOrig
def getEmptyCol(): def getEmptyCol():
col = getEmptyColOrig() col = getEmptyColOrig()
# Disable FSRS for legacy scheduler tests
col.set_config_bool(Config.Bool.FSRS, False, undoable=False)
return col return col

View file

@ -40,6 +40,7 @@ impl From<BoolKeyProto> for BoolKey {
BoolKeyProto::LoadBalancerEnabled => BoolKey::LoadBalancerEnabled, BoolKeyProto::LoadBalancerEnabled => BoolKey::LoadBalancerEnabled,
BoolKeyProto::FsrsShortTermWithStepsEnabled => BoolKey::FsrsShortTermWithStepsEnabled, BoolKeyProto::FsrsShortTermWithStepsEnabled => BoolKey::FsrsShortTermWithStepsEnabled,
BoolKeyProto::FsrsLegacyEvaluate => BoolKey::FsrsLegacyEvaluate, BoolKeyProto::FsrsLegacyEvaluate => BoolKey::FsrsLegacyEvaluate,
BoolKeyProto::Fsrs => BoolKey::Fsrs,
} }
} }
} }

View file

@ -79,6 +79,7 @@ impl Collection {
| BoolKey::RestorePositionReviewer | BoolKey::RestorePositionReviewer
| BoolKey::LoadBalancerEnabled | BoolKey::LoadBalancerEnabled
| BoolKey::FsrsHealthCheck | BoolKey::FsrsHealthCheck
| BoolKey::Fsrs
| BoolKey::NormalizeNoteText => self.get_config_optional(key).unwrap_or(true), | BoolKey::NormalizeNoteText => self.get_config_optional(key).unwrap_or(true),
// other options default to false // other options default to false

View file

@ -25,6 +25,7 @@ pub(crate) fn schema11_config_as_string(creation_offset: Option<i32>) -> String
"schedVer": 2, "schedVer": 2,
"creationOffset": creation_offset, "creationOffset": creation_offset,
"sched2021": true, "sched2021": true,
"fsrs": true,
}); });
serde_json::to_string(&obj).unwrap() serde_json::to_string(&obj).unwrap()
} }

View file

@ -501,7 +501,7 @@ mod test {
limits: Limits::default(), limits: Limits::default(),
new_cards_ignore_review_limit: false, new_cards_ignore_review_limit: false,
apply_all_parent_limits: false, apply_all_parent_limits: false,
fsrs: false, fsrs: true,
fsrs_reschedule: false, fsrs_reschedule: false,
fsrs_health_check: true, fsrs_health_check: true,
}; };

View file

@ -706,6 +706,8 @@ pub(crate) mod test {
#[test] #[test]
fn state_application() -> Result<()> { fn state_application() -> Result<()> {
let mut col = Collection::new(); let mut col = Collection::new();
// Disable FSRS for this legacy scheduler test
col.set_config_bool(BoolKey::Fsrs, false, false)?;
if col.timing_today()?.near_cutoff() { if col.timing_today()?.near_cutoff() {
return Ok(()); return Ok(());
} }

View file

@ -431,6 +431,8 @@ mod test {
#[test] #[test]
fn review_queue_building() -> Result<()> { fn review_queue_building() -> Result<()> {
let mut col = Collection::new(); let mut col = Collection::new();
// Disable FSRS for this legacy scheduler test
col.set_config_bool(BoolKey::Fsrs, false, 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();

View file

@ -100,6 +100,8 @@ mod test {
fn undo() -> Result<()> { fn undo() -> Result<()> {
// add a note // add a note
let mut col = Collection::new(); let mut col = Collection::new();
// Disable FSRS for this legacy scheduler test
col.set_config_bool(BoolKey::Fsrs, false, false)?;
let nid = add_note(&mut col, true)?; let nid = add_note(&mut col, true)?;
// turn burying and leech suspension on // turn burying and leech suspension on

View file

@ -96,7 +96,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
/> />
<DynamicallySlottable slotHost={Item} {api}> <DynamicallySlottable slotHost={Item} {api}>
<Item> <Item>
<SwitchRow bind:value={$fsrs} defaultValue={false}> <SwitchRow bind:value={$fsrs} defaultValue={true}>
<SettingTitle <SettingTitle
on:click={() => on:click={() =>
openHelpModal(Object.keys(settings).indexOf("fsrs"))} openHelpModal(Object.keys(settings).indexOf("fsrs"))}