From 3e846c87565fae48c076d7a241caea392e12b330 Mon Sep 17 00:00:00 2001 From: user1823 <92206575+user1823@users.noreply.github.com> Date: Tue, 19 Aug 2025 22:33:53 +0530 Subject: [PATCH] Make simulator fill missing values of DR and decay too (#4269) * Make simulator fill missing values of DR and decay too If a card has missing memory states, it will likely have missing DR and decay too. So, it makes sense to simultaneously update them as well. * Fix error * Avoid causing sync conflicts when filling in missing memory in sim https://github.com/ankitects/anki/pull/4269#issuecomment-3201450124 --------- Co-authored-by: Damien Elmes --- rslib/src/scheduler/fsrs/simulator.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/rslib/src/scheduler/fsrs/simulator.rs b/rslib/src/scheduler/fsrs/simulator.rs index c1f4df817..005f7ca86 100644 --- a/rslib/src/scheduler/fsrs/simulator.rs +++ b/rslib/src/scheduler/fsrs/simulator.rs @@ -142,10 +142,11 @@ impl Collection { // calculate any missing memory state for c in &mut cards { if is_included_card(c) && c.memory_state.is_none() { - let original = c.clone(); - let new_state = self.compute_memory_state(c.id)?.state; - c.memory_state = new_state.map(Into::into); - self.update_card_inner(c, original, self.usn()?)?; + let fsrs_data = self.compute_memory_state(c.id)?; + c.memory_state = fsrs_data.state.map(Into::into); + c.desired_retention = Some(fsrs_data.desired_retention); + c.decay = Some(fsrs_data.decay); + self.storage.update_card(c)?; } } let days_elapsed = self.timing_today().unwrap().days_elapsed as i32;