Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Added: Leech suspend to simulator
  • Loading branch information
Luc-Mcgrady committed Feb 27, 2025
commit b28ac4e6460a13dd234bc4a17e2c4b10b17fb97f
2 changes: 2 additions & 0 deletions proto/anki/scheduler.proto
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ message SimulateFsrsReviewRequest {
bool new_cards_ignore_review_limit = 9;
repeated float easy_days_percentages = 10;
deck_config.DeckConfig.Config.ReviewCardOrder review_order = 11;
optional uint32 suspend_after_lapse_count = 12;
}

message SimulateFsrsReviewResponse {
Expand All @@ -409,6 +410,7 @@ message ComputeOptimalRetentionRequest {
string search = 4;
double loss_aversion = 5;
repeated float easy_days_percentages = 6;
optional uint32 suspend_after_lapse_count = 7;
}

message ComputeOptimalRetentionResponse {
Expand Down
1 change: 1 addition & 0 deletions rslib/src/scheduler/fsrs/retention.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ impl Collection {
learn_limit,
review_limit: usize::MAX,
new_cards_ignore_review_limit: true,
suspend_after_lapses: None,
post_scheduling_fn,
review_priority_fn: None,
},
Expand Down
4 changes: 4 additions & 0 deletions rslib/src/scheduler/fsrs/simulator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ impl Collection {
last_date: f32::NEG_INFINITY, // Treated as a new card in simulation
due: ((introduced_today_count + i) / req.new_limit as usize) as f32,
interval: f32::NEG_INFINITY,
lapses: 0
});
converted_cards.extend(new_cards);
}
Expand Down Expand Up @@ -198,6 +199,7 @@ impl Collection {
learn_limit: req.new_limit as usize,
review_limit: req.review_limit as usize,
new_cards_ignore_review_limit: req.new_cards_ignore_review_limit,
suspend_after_lapses: req.suspend_after_lapse_count,
post_scheduling_fn,
review_priority_fn,
};
Expand Down Expand Up @@ -239,6 +241,7 @@ impl Card {
last_date,
due: relative_due as f32,
interval: card.interval as f32,
lapses: card.lapses
})
}
CardQueue::New => None,
Expand All @@ -249,6 +252,7 @@ impl Card {
last_date: 0.0,
due: 0.0,
interval: card.interval as f32,
lapses: card.lapses
})
}
CardQueue::PreviewRepeat => None,
Expand Down
9 changes: 9 additions & 0 deletions ts/routes/deck-options/SimulatorModal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import SpinBoxFloatRow from "./SpinBoxFloatRow.svelte";
import { reviewOrderChoices } from "./choices";
import EnumSelectorRow from "$lib/components/EnumSelectorRow.svelte";
import { DeckConfig_Config_LeechAction } from "@generated/anki/deck_config_pb";

export let shown = false;
export let state: DeckOptionsState;
Expand All @@ -48,6 +49,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
let points: Point[] = [];
const newCardsIgnoreReviewLimit = state.newCardsIgnoreReviewLimit;
let smooth = true;
let suspendLeeches = $config.leechAction == DeckConfig_Config_LeechAction.SUSPEND;

$: daysToSimulate = 365;
$: deckSize = 0;
Expand Down Expand Up @@ -75,6 +77,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
let resp: SimulateFsrsReviewResponse | undefined;
simulateFsrsRequest.daysToSimulate = daysToSimulate;
simulateFsrsRequest.deckSize = deckSize;
simulateFsrsRequest.suspendAfterLapseCount = suspendLeeches ? $config.leechThreshold : undefined
try {
await runWithBackendProgress(
async () => {
Expand Down Expand Up @@ -271,6 +274,12 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
</SettingTitle>
</SwitchRow>

<SwitchRow bind:value={suspendLeeches} defaultValue={suspendLeeches}>
<SettingTitle on:click={() => openHelpModal("simulateFsrsReview")}>
{"Suspend Leeches"}
</SettingTitle>
</SwitchRow>

<button
class="btn {computing ? 'btn-warning' : 'btn-primary'}"
disabled={computing}
Expand Down