From 90f2e06b1769f392aaf2cdc4177c6b65f8ca61d3 Mon Sep 17 00:00:00 2001 From: Jarrett Ye Date: Sun, 27 Apr 2025 15:20:13 +0800 Subject: [PATCH] Fix/missing-simulator-decay-for-FSRS-5 (#3956) --- Cargo.lock | 5 ++--- Cargo.toml | 6 +++--- cargo/licenses.json | 2 +- rslib/src/scheduler/fsrs/simulator.rs | 19 +++++++++---------- 4 files changed, 15 insertions(+), 17 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 29347399d..db523e2ef 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2099,9 +2099,8 @@ dependencies = [ [[package]] name = "fsrs" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7e39017be91629761c3a2802032eb38d226227e1a21433381da4310612199ee" +version = "4.0.0" +source = "git+https://github.com/open-spaced-repetition/fsrs-rs.git?rev=2fb2ac7f7a4d14d07663fe5698ba5e95e3f78ebd#2fb2ac7f7a4d14d07663fe5698ba5e95e3f78ebd" dependencies = [ "burn", "itertools 0.14.0", diff --git a/Cargo.toml b/Cargo.toml index cc533c03a..051c038a7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,9 +35,9 @@ git = "https://github.com/ankitects/linkcheck.git" rev = "184b2ca50ed39ca43da13f0b830a463861adb9ca" [workspace.dependencies.fsrs] -version = "3.0.0" -# git = "https://github.com/open-spaced-repetition/fsrs-rs.git" -# rev = "c7717682997a8a6d53d97c7196281e745c5b3c8e" +# version = "3.0.0" +git = "https://github.com/open-spaced-repetition/fsrs-rs.git" +rev = "2fb2ac7f7a4d14d07663fe5698ba5e95e3f78ebd" # path = "../open-spaced-repetition/fsrs-rs" [workspace.dependencies] diff --git a/cargo/licenses.json b/cargo/licenses.json index 441aaed94..e2232690f 100644 --- a/cargo/licenses.json +++ b/cargo/licenses.json @@ -1360,7 +1360,7 @@ }, { "name": "fsrs", - "version": "3.0.0", + "version": "4.0.0", "authors": "Open Spaced Repetition", "repository": "https://github.com/open-spaced-repetition/fsrs-rs", "license": "BSD-3-Clause", diff --git a/rslib/src/scheduler/fsrs/simulator.rs b/rslib/src/scheduler/fsrs/simulator.rs index d04e57125..144741f0a 100644 --- a/rslib/src/scheduler/fsrs/simulator.rs +++ b/rslib/src/scheduler/fsrs/simulator.rs @@ -75,7 +75,6 @@ pub(crate) fn apply_load_balance_and_easy_days( fn create_review_priority_fn( review_order: ReviewCardOrder, deck_size: usize, - params: Vec, ) -> Option { // Helper macro to wrap closure in ReviewPriorityFn macro_rules! wrap { @@ -86,28 +85,28 @@ fn create_review_priority_fn( match review_order { // Ease-based ordering - EaseAscending => wrap!(|c| -(c.difficulty * 100.0) as i32), - EaseDescending => wrap!(|c| (c.difficulty * 100.0) as i32), + EaseAscending => wrap!(|c, _w| -(c.difficulty * 100.0) as i32), + EaseDescending => wrap!(|c, _w| (c.difficulty * 100.0) as i32), // Interval-based ordering - IntervalsAscending => wrap!(|c| c.interval as i32), - IntervalsDescending => wrap!(|c| -(c.interval as i32)), + IntervalsAscending => wrap!(|c, _w| c.interval as i32), + IntervalsDescending => wrap!(|c, _w| -(c.interval as i32)), // Retrievability-based ordering RetrievabilityAscending => { - wrap!(move |c| (c.retrievability(¶ms) * 1000.0) as i32) + wrap!(move |c, w| (c.retrievability(w) * 1000.0) as i32) } RetrievabilityDescending => { - wrap!(move |c| -(c.retrievability(¶ms) * 1000.0) as i32) + wrap!(move |c, w| -(c.retrievability(w) * 1000.0) as i32) } // Due date ordering Day | DayThenDeck | DeckThenDay => { - wrap!(|c| c.scheduled_due() as i32) + wrap!(|c, _w| c.scheduled_due() as i32) } // Random ordering Random => { - wrap!(move |_| rand::thread_rng().gen_range(0..deck_size) as i32) + wrap!(move |_c, _w| rand::thread_rng().gen_range(0..deck_size) as i32) } // Not implemented yet @@ -197,7 +196,7 @@ impl Collection { .review_order .try_into() .ok() - .and_then(|order| create_review_priority_fn(order, deck_size, req.params.clone())); + .and_then(|order| create_review_priority_fn(order, deck_size)); let config = SimulatorConfig { deck_size,