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

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion .vscode.dist/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"editor.formatOnSave": true,
"[python]": {
"editor.codeActionsOnSave": {
"source.organizeImports": true
"source.organizeImports": "explicit"
}
},
"files.watcherExclude": {
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ rev = "184b2ca50ed39ca43da13f0b830a463861adb9ca"
[workspace.dependencies.fsrs]
# version = "=2.0.3"
git = "https://github.com/open-spaced-repetition/fsrs-rs.git"
rev = "96520531415e032781adfe212f8a5eed216006be"
rev = "22f8e453c120f5bc5996f86558a559c6b7abfc49"
# path = "../open-spaced-repetition/fsrs-rs"

[workspace.dependencies]
Expand Down
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
5 changes: 3 additions & 2 deletions rslib/src/scheduler/fsrs/retention.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ impl Collection {
let post_scheduling_fn: Option<PostSchedulingFn> =
if self.get_config_bool(BoolKey::LoadBalancerEnabled) {
Some(PostSchedulingFn(Arc::new(
move |interval, max_interval, today, due_cnt_per_day, rng| {
move |card, max_interval, today, due_cnt_per_day, rng| {
apply_load_balance_and_easy_days(
interval,
card.interval,
max_interval,
today,
due_cnt_per_day,
Expand Down 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
11 changes: 9 additions & 2 deletions rslib/src/scheduler/fsrs/simulator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,13 @@ impl Collection {
.min(req.new_limit as usize);
if req.new_limit > 0 {
let new_cards = (0..new_cards).map(|i| fsrs::Card {
id: -(i as i64),
difficulty: f32::NEG_INFINITY,
stability: 1e-8, // Not filtered by fsrs-rs
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 All @@ -159,9 +161,9 @@ impl Collection {
let post_scheduling_fn: Option<PostSchedulingFn> =
if self.get_config_bool(BoolKey::LoadBalancerEnabled) {
Some(PostSchedulingFn(Arc::new(
move |interval, max_interval, today, due_cnt_per_day, rng| {
move |card, max_interval, today, due_cnt_per_day, rng| {
apply_load_balance_and_easy_days(
interval,
card.interval,
max_interval,
today,
due_cnt_per_day,
Expand Down Expand Up @@ -198,6 +200,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 @@ -234,21 +237,25 @@ impl Card {
let relative_due = due - days_elapsed;
let last_date = (relative_due - card.interval as i32).min(0) as f32;
Some(fsrs::Card {
id: card.id.0,
difficulty: state.difficulty,
stability: state.stability,
last_date,
due: relative_due as f32,
interval: card.interval as f32,
lapses: card.lapses,
})
}
CardQueue::New => None,
CardQueue::Learn | CardQueue::SchedBuried | CardQueue::UserBuried => {
Some(fsrs::Card {
id: card.id.0,
difficulty: state.difficulty,
stability: state.stability,
last_date: 0.0,
due: 0.0,
interval: card.interval as f32,
lapses: card.lapses,
})
}
CardQueue::PreviewRepeat => None,
Expand Down
82 changes: 2 additions & 80 deletions ts/routes/deck-options/EasyDays.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import TitledContainer from "$lib/components/TitledContainer.svelte";
import type { DeckOptionsState } from "./lib";
import Warning from "./Warning.svelte";
import EasyDaysInput from "./EasyDaysInput.svelte";

export let state: DeckOptionsState;
export let api: Record<string, never>;
Expand All @@ -35,16 +36,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
easyDaysChanged && !($fsrsEnabled && $reschedule)
? tr.deckConfigEasyDaysChange()
: "";

const easyDays = [
tr.deckConfigEasyDaysMonday(),
tr.deckConfigEasyDaysTuesday(),
tr.deckConfigEasyDaysWednesday(),
tr.deckConfigEasyDaysThursday(),
tr.deckConfigEasyDaysFriday(),
tr.deckConfigEasyDaysSaturday(),
tr.deckConfigEasyDaysSunday(),
];
</script>

<datalist id="easy_day_steplist">
Expand All @@ -53,43 +44,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html

<TitledContainer title={tr.deckConfigEasyDaysTitle()}>
<DynamicallySlottable slotHost={Item} {api}>
<Item>
<div class="easy-days-settings">
<table>
<thead>
<tr>
<th></th>
<th class="header min-col">
<span>{tr.deckConfigEasyDaysMinimum()}</span>
</th>
<th class="header text-center">
<span>{tr.deckConfigEasyDaysReduced()}</span>
</th>
<th class="header normal-col">
<span>{tr.deckConfigEasyDaysNormal()}</span>
</th>
</tr>
</thead>
<tbody>
{#each easyDays as day, index}
<tr>
<td class="day">{day}</td>
<td colspan="3">
<input
type="range"
bind:value={$config.easyDaysPercentages[index]}
step={0.5}
max={1.0}
min={0.0}
list="easy_day_steplist"
/>
</td>
</tr>
{/each}
</tbody>
</table>
</div>
</Item>
<EasyDaysInput bind:values={$config.easyDaysPercentages} />
<Item>
<Warning warning={noNormalDay} />
</Item>
Expand All @@ -98,36 +53,3 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
</Item>
</DynamicallySlottable>
</TitledContainer>

<style>
.easy-days-settings table {
width: 100%;
border-collapse: collapse;
table-layout: fixed;
}
.easy-days-settings th,
.easy-days-settings td {
padding: 8px;
border-bottom: var(--border) solid 1px;
}
.header {
word-wrap: break-word;
font-size: smaller;
}
.easy-days-settings input[type="range"] {
width: 100%;
}

.day {
word-wrap: break-word;
font-size: smaller;
}

.min-col {
text-align: start;
}

.normal-col {
text-align: end;
}
</style>
91 changes: 91 additions & 0 deletions ts/routes/deck-options/EasyDaysInput.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<!--
Copyright: Ankitects Pty Ltd and contributors
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
-->
<script>
import * as tr from "@generated/ftl";
import Item from "$lib/components/Item.svelte";

const easyDays = [
tr.deckConfigEasyDaysMonday(),
tr.deckConfigEasyDaysTuesday(),
tr.deckConfigEasyDaysWednesday(),
tr.deckConfigEasyDaysThursday(),
tr.deckConfigEasyDaysFriday(),
tr.deckConfigEasyDaysSaturday(),
tr.deckConfigEasyDaysSunday(),
];

export let values = [0, 0, 0, 0, 0, 0, 0];
</script>

<Item>
<div class="easy-days-settings">
<table>
<thead>
<tr>
<th></th>
<th class="header min-col">
<span>{tr.deckConfigEasyDaysMinimum()}</span>
</th>
<th class="header text-center">
<span>{tr.deckConfigEasyDaysReduced()}</span>
</th>
<th class="header normal-col">
<span>{tr.deckConfigEasyDaysNormal()}</span>
</th>
</tr>
</thead>
<tbody>
{#each easyDays as day, index}
<tr>
<td class="day">{day}</td>
<td colspan="3">
<input
type="range"
bind:value={values[index]}
step={0.5}
max={1.0}
min={0.0}
list="easy_day_steplist"
/>
</td>
</tr>
{/each}
</tbody>
</table>
</div>
</Item>

<style>
.easy-days-settings table {
width: 100%;
border-collapse: collapse;
table-layout: fixed;
}
.easy-days-settings th,
.easy-days-settings td {
padding: 8px;
border-bottom: var(--border) solid 1px;
}
.header {
word-wrap: break-word;
font-size: smaller;
}
.easy-days-settings input[type="range"] {
width: 100%;
}

.day {
word-wrap: break-word;
font-size: smaller;
}

.min-col {
text-align: start;
}

.normal-col {
text-align: end;
}
</style>
Loading