From d1b2ab5983a1079347a6726f87d65b3166bd5366 Mon Sep 17 00:00:00 2001 From: Jarrett Ye Date: Wed, 17 Apr 2024 18:18:00 +0800 Subject: [PATCH] Return current weights if fsrs items is zero & handle error in evaluation and optimal retention (#3141) * return current weights if fsrs_items is zero * handle error of evaluation if items.is_empty() * TODO: handle error of optimal retention * Revert "TODO: handle error of optimal retention" This reverts commit 80a5b3803ef4b8270d13aabb9a832291b55d4847. * Revert "handle error of evaluation if items.is_empty()" This reverts commit 7f0a5570e74ba5236fc02942550b4e00046b71bc. --- rslib/src/scheduler/fsrs/weights.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/rslib/src/scheduler/fsrs/weights.rs b/rslib/src/scheduler/fsrs/weights.rs index 19c13b51c..93957a69b 100644 --- a/rslib/src/scheduler/fsrs/weights.rs +++ b/rslib/src/scheduler/fsrs/weights.rs @@ -65,6 +65,12 @@ impl Collection { fsrs_items_for_training(revlogs.clone(), timing.next_day_at, ignore_revlogs_before); let fsrs_items = items.len() as u32; + if fsrs_items == 0 { + return Ok(ComputeFsrsWeightsResponse { + weights: current_weights.to_vec(), + fsrs_items, + }); + } anki_progress.update(false, |p| { p.current_preset = current_preset; p.total_presets = total_presets;