Update to latest FSRS

This commit is contained in:
Damien Elmes 2023-11-27 09:39:10 +10:00
parent 3713c86373
commit c67f510b9a
8 changed files with 14 additions and 10 deletions

2
Cargo.lock generated
View File

@ -1457,7 +1457,7 @@ dependencies = [
[[package]]
name = "fsrs"
version = "0.1.0"
source = "git+https://github.com/open-spaced-repetition/fsrs-rs.git?rev=67163045ba9916e8a41f384fdb5ea414773139bd#67163045ba9916e8a41f384fdb5ea414773139bd"
source = "git+https://github.com/open-spaced-repetition/fsrs-rs.git?rev=96ae7fca09f17723ec514a1d633d36c3a09779f4#96ae7fca09f17723ec514a1d633d36c3a09779f4"
dependencies = [
"burn",
"itertools 0.11.0",

View File

@ -36,7 +36,7 @@ rev = "184b2ca50ed39ca43da13f0b830a463861adb9ca"
[workspace.dependencies.fsrs]
git = "https://github.com/open-spaced-repetition/fsrs-rs.git"
rev = "67163045ba9916e8a41f384fdb5ea414773139bd"
rev = "96ae7fca09f17723ec514a1d633d36c3a09779f4"
# path = "../../../fsrs-rs"
[workspace.dependencies]

View File

@ -330,6 +330,8 @@ deck-config-which-deck = Which deck would you like to display options for?
deck-config-updating-cards = Updating cards: { $current_cards_count }/{ $total_cards_count }...
deck-config-invalid-weights = Parameters must be either left blank to use the defaults, or must be 17 comma-separated numbers.
deck-config-not-enough-history = Insufficient review history to perform this operation.
deck-config-unable-to-determine-desired-retention =
Unable to determine an optimal retention.
deck-config-must-have-1000-reviews =
{ $count ->
[one] Only { $count } review was found.
@ -352,6 +354,7 @@ deck-config-fsrs-on-all-clients =
not work correctly if one of your clients is older.
deck-config-estimated-retention = Estimated retention: { $num }
deck-config-complete = { $num }% complete.
deck-config-iterations = Iteration: { $count }...
deck-config-reschedule-cards-on-change = Reschedule cards on change
deck-config-fsrs-tooltip =
The Free Spaced Repetition Scheduler (FSRS) is an alternative to Anki's legacy SuperMemo 2 (SM2) scheduler.

View File

@ -43,6 +43,7 @@ impl AnkiError {
AnkiError::InvalidMethodIndex
| AnkiError::InvalidServiceIndex
| AnkiError::FsrsWeightsInvalid
| AnkiError::FsrsUnableToDetermineDesiredRetention
| AnkiError::FsrsInsufficientData => Kind::InvalidInput,
#[cfg(windows)]
AnkiError::WindowsError { .. } => Kind::OsError,

View File

@ -115,6 +115,7 @@ pub enum AnkiError {
InvalidServiceIndex,
FsrsWeightsInvalid,
FsrsInsufficientData,
FsrsUnableToDetermineDesiredRetention,
SchedulerUpgradeRequired,
}
@ -174,6 +175,9 @@ impl AnkiError {
}
#[cfg(windows)]
AnkiError::WindowsError { source } => format!("{source:?}"),
AnkiError::FsrsUnableToDetermineDesiredRetention => tr
.deck_config_unable_to_determine_desired_retention()
.into(),
}
}

View File

@ -9,6 +9,7 @@ impl From<FSRSError> for AnkiError {
fn from(err: FSRSError) -> Self {
match err {
FSRSError::NotEnoughData => AnkiError::FsrsInsufficientData,
FSRSError::OptimalNotFound => AnkiError::FsrsUnableToDetermineDesiredRetention,
FSRSError::Interrupted => AnkiError::Interrupted,
FSRSError::InvalidWeights => AnkiError::FsrsWeightsInvalid,
}

View File

@ -55,7 +55,6 @@ impl Collection {
|ip| {
anki_progress
.update(false, |p| {
p.total = ip.total as u32;
p.current = ip.current as u32;
})
.is_ok()

View File

@ -180,10 +180,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
optimalRetentionRequest.search = `preset:"${state.getCurrentName()}"`;
const resp = await computeOptimalRetention(optimalRetentionRequest);
optimalRetention = resp.optimalRetention;
if (computeRetentionProgress) {
computeRetentionProgress.current =
computeRetentionProgress.total;
}
computeRetentionProgress = undefined;
},
(progress) => {
if (progress.value.case === "computeRetention") {
@ -217,11 +214,10 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
function renderRetentionProgress(
val: ComputeRetentionProgress | undefined,
): String {
if (!val || !val.total) {
if (!val) {
return "";
}
const pct = ((val.current / val.total) * 100).toFixed(0);
return tr.deckConfigComplete({ num: pct });
return tr.deckConfigIterations({ count: val.current });
}
function estimatedRetention(retention: number): String {