Skip to content

Commit

Permalink
handle error of evaluation if items.is_empty()
Browse files Browse the repository at this point in the history
  • Loading branch information
L-M-Sherlock committed Apr 14, 2024
1 parent e269983 commit 7f0a557
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions rslib/src/scheduler/fsrs/weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ impl Collection {
.get_revlog_entries_for_searched_cards_in_card_order()?;
let (items, review_count) =
fsrs_items_for_training(revlogs, timing.next_day_at, ignore_revlogs_before);
if items.is_empty() {
return Err(AnkiError::FsrsInsufficientData);
}
anki_progress.state.reviews = review_count as u32;
let fsrs = FSRS::new(Some(weights))?;
Ok(fsrs.evaluate(items, |ip| {
Expand Down
2 changes: 2 additions & 0 deletions ts/routes/deck-options/FsrsOptions.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
}
},
);
} catch (err) {
alert(tr.deckConfigNotEnoughHistory());
} finally {
checkingWeights = false;
}
Expand Down

0 comments on commit 7f0a557

Please sign in to comment.