alert when the resp.weights is empty (#3061)

* alert when the resp.weights is empty

* format
This commit is contained in:
Jarrett Ye 2024-03-09 18:26:59 +08:00 committed by GitHub
parent 6ac60f8032
commit f2acf40221
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 8 additions and 9 deletions

View file

@ -346,10 +346,8 @@ impl Collection {
&config.inner.fsrs_weights,
) {
Ok(weights) => {
if weights.fsrs_items >= 1000 {
println!("{}: {:?}", config.name, weights.weights);
config.inner.fsrs_weights = weights.weights;
}
println!("{}: {:?}", config.name, weights.weights);
config.inner.fsrs_weights = weights.weights;
}
Err(AnkiError::Interrupted) => return Err(AnkiError::Interrupted),
Err(err) => {

View file

@ -96,7 +96,7 @@ impl Collection {
let mut weights =
fsrs.compute_parameters(items.clone(), fsrs_items < 1000, Some(progress2))?;
let metrics = fsrs.universal_metrics(items, &weights, |_| true)?;
if metrics.0 < metrics.1 {
if metrics.0 <= metrics.1 {
weights = current_weights.to_vec();
}

View file

@ -117,10 +117,11 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
currentWeights: $config.fsrsWeights,
});
if (
$config.fsrsWeights.length &&
$config.fsrsWeights.every(
(n, i) => n.toFixed(4) === resp.weights[i].toFixed(4),
)
($config.fsrsWeights.length &&
$config.fsrsWeights.every(
(n, i) => n.toFixed(4) === resp.weights[i].toFixed(4),
)) ||
resp.weights.length === 0
) {
alert(tr.deckConfigFsrsParamsOptimal());
}