@@ -7,13 +7,9 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
7
7
ComputeRetentionProgress ,
8
8
type ComputeParamsProgress ,
9
9
} from " @generated/anki/collection_pb" ;
10
- import {
11
- ComputeOptimalRetentionRequest ,
12
- SimulateFsrsReviewRequest ,
13
- } from " @generated/anki/scheduler_pb" ;
10
+ import { SimulateFsrsReviewRequest } from " @generated/anki/scheduler_pb" ;
14
11
import {
15
12
computeFsrsParams ,
16
- computeOptimalRetention ,
17
13
evaluateParams ,
18
14
setWantsAbort ,
19
15
} from " @generated/backend" ;
@@ -26,7 +22,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
26
22
import GlobalLabel from " ./GlobalLabel.svelte" ;
27
23
import { commitEditing , fsrsParams , type DeckOptionsState } from " ./lib" ;
28
24
import SpinBoxFloatRow from " ./SpinBoxFloatRow.svelte" ;
29
- import SpinBoxRow from " ./SpinBoxRow.svelte" ;
30
25
import Warning from " ./Warning.svelte" ;
31
26
import ParamsInputRow from " ./ParamsInputRow.svelte" ;
32
27
import ParamsSearchRow from " ./ParamsSearchRow.svelte" ;
@@ -37,8 +32,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
37
32
export let openHelpModal: (String ) => void ;
38
33
export let onPresetChange: () => void ;
39
34
40
- const presetName = state .currentPresetName ;
41
-
42
35
const config = state .currentConfig ;
43
36
const defaults = state .defaults ;
44
37
const fsrsReschedule = state .fsrsReschedule ;
@@ -50,13 +43,8 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
50
43
let computeParamsProgress: ComputeParamsProgress | undefined ;
51
44
let computingParams = false ;
52
45
let checkingParams = false ;
53
- let computingRetention = false ;
54
46
55
- let optimalRetention = 0 ;
56
- $ : if ($presetName ) {
57
- optimalRetention = 0 ;
58
- }
59
- $ : computing = computingParams || checkingParams || computingRetention ;
47
+ $ : computing = computingParams || checkingParams ;
60
48
$ : defaultparamSearch = ` preset:"${state .getCurrentNameForSearch ()}" -is:suspended ` ;
61
49
$ : roundedRetention = Number ($config .desiredRetention .toFixed (2 ));
62
50
$ : desiredRetentionWarning = getRetentionWarning (
@@ -65,19 +53,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
65
53
);
66
54
$ : retentionWarningClass = getRetentionWarningClass (roundedRetention );
67
55
68
- let computeRetentionProgress:
69
- | ComputeParamsProgress
70
- | ComputeRetentionProgress
71
- | undefined ;
72
-
73
- const optimalRetentionRequest = new ComputeOptimalRetentionRequest ({
74
- daysToSimulate: 365 ,
75
- lossAversion: 2.5 ,
76
- });
77
- $ : if (optimalRetentionRequest .daysToSimulate > 3650 ) {
78
- optimalRetentionRequest .daysToSimulate = 3650 ;
79
- }
80
-
81
56
$ : newCardsIgnoreReviewLimit = state .newCardsIgnoreReviewLimit ;
82
57
83
58
$ : simulateFsrsRequest = new SimulateFsrsReviewRequest ({
@@ -233,44 +208,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
233
208
}
234
209
}
235
210
236
- async function computeRetention(): Promise <void > {
237
- if (computingRetention ) {
238
- await setWantsAbort ({});
239
- return ;
240
- }
241
- if (state .presetAssignmentsChanged ()) {
242
- alert (tr .deckConfigPleaseSaveYourChangesFirst ());
243
- return ;
244
- }
245
- computingRetention = true ;
246
- computeRetentionProgress = undefined ;
247
- try {
248
- await runWithBackendProgress (
249
- async () => {
250
- optimalRetentionRequest .maxInterval = $config .maximumReviewInterval ;
251
- optimalRetentionRequest .params = fsrsParams ($config );
252
- optimalRetentionRequest .search = ` preset:"${state .getCurrentNameForSearch ()}" -is:suspended ` ;
253
- optimalRetentionRequest .easyDaysPercentages =
254
- $config .easyDaysPercentages ;
255
- const resp = await computeOptimalRetention (optimalRetentionRequest );
256
- optimalRetention = resp .optimalRetention ;
257
- computeRetentionProgress = undefined ;
258
- },
259
- (progress ) => {
260
- if (progress .value .case === " computeRetention" ) {
261
- computeRetentionProgress = progress .value .value ;
262
- }
263
- },
264
- );
265
- } finally {
266
- computingRetention = false ;
267
- }
268
- }
269
-
270
211
$ : computeParamsProgressString = renderWeightProgress (computeParamsProgress );
271
- $ : computeRetentionProgressString = renderRetentionProgress (
272
- computeRetentionProgress ,
273
- );
274
212
$ : totalReviews = computeParamsProgress ?.reviews ?? undefined ;
275
213
276
214
function renderWeightProgress(val : ComputeParamsProgress | undefined ): String {
@@ -285,22 +223,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
285
223
}
286
224
}
287
225
288
- function renderRetentionProgress(
289
- val : ComputeRetentionProgress | undefined ,
290
- ): String {
291
- if (! val ) {
292
- return " " ;
293
- }
294
- return tr .deckConfigIterations ({ count: val .current });
295
- }
296
-
297
- function estimatedRetention(retention : number ): String {
298
- if (! retention ) {
299
- return " " ;
300
- }
301
- return tr .deckConfigPredictedOptimalRetention ({ num: retention .toFixed (2 ) });
302
- }
303
-
304
226
async function computeAllParams(): Promise <void > {
305
227
await commitEditing ();
306
228
state .save (UpdateDeckConfigsMode .COMPUTE_ALL_PARAMS );
@@ -390,49 +312,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
390
312
{/if }
391
313
</div >
392
314
393
- <div class =" m-2" >
394
- <details >
395
- <summary >{tr .deckConfigComputeOptimalRetention ()}</summary >
396
-
397
- <SpinBoxRow
398
- bind:value ={optimalRetentionRequest .daysToSimulate }
399
- defaultValue ={365 }
400
- min ={1 }
401
- max ={3650 }
402
- >
403
- <SettingTitle on:click ={() => openHelpModal (" computeOptimalRetention" )}>
404
- {tr .deckConfigDaysToSimulate ()}
405
- </SettingTitle >
406
- </SpinBoxRow >
407
-
408
- <button
409
- class ="btn {computingRetention ? ' btn-warning' : ' btn-primary' }"
410
- disabled ={! computingRetention && computing }
411
- on:click ={() => computeRetention ()}
412
- >
413
- {#if computingRetention }
414
- {tr .actionsCancel ()}
415
- {:else }
416
- {tr .deckConfigComputeButton ()}
417
- {/if }
418
- </button >
419
-
420
- {#if optimalRetention }
421
- {estimatedRetention (optimalRetention )}
422
- {#if optimalRetention - $config .desiredRetention >= 0.01 }
423
- <Warning
424
- warning ={tr .deckConfigDesiredRetentionBelowOptimal ()}
425
- className =" alert-warning"
426
- />
427
- {/if }
428
- {/if }
429
-
430
- {#if computingRetention }
431
- <div >{computeRetentionProgressString }</div >
432
- {/if }
433
- </details >
434
- </div >
435
-
436
315
<div class =" m-2" >
437
316
<button class ="btn btn-primary" on:click ={() => (showSimulator = true )}>
438
317
{tr .deckConfigFsrsSimulatorExperimental ()}
0 commit comments