mirror of
https://github.com/ankitects/anki.git
synced 2025-09-25 09:16:38 -04:00
slapdash frontend
This commit is contained in:
parent
caadd9336d
commit
005b4b7147
2 changed files with 55 additions and 5 deletions
|
@ -654,6 +654,7 @@ exposed_backend_list = [
|
|||
"evaluate_params_legacy",
|
||||
"get_optimal_retention_parameters",
|
||||
"simulate_fsrs_review",
|
||||
"simulate_fsrs_workload",
|
||||
# DeckConfigService
|
||||
"get_ignored_before_count",
|
||||
"get_retention_workload",
|
||||
|
|
|
@ -16,12 +16,17 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
import { SimulateSubgraph, type Point } from "../graphs/simulator";
|
||||
import * as tr from "@generated/ftl";
|
||||
import { renderSimulationChart } from "../graphs/simulator";
|
||||
import { computeOptimalRetention, simulateFsrsReview } from "@generated/backend";
|
||||
import {
|
||||
computeOptimalRetention,
|
||||
simulateFsrsReview,
|
||||
simulateFsrsWorkload,
|
||||
} from "@generated/backend";
|
||||
import { runWithBackendProgress } from "@tslib/progress";
|
||||
import type {
|
||||
ComputeOptimalRetentionResponse,
|
||||
SimulateFsrsReviewRequest,
|
||||
SimulateFsrsReviewResponse,
|
||||
SimulateFsrsWorkloadResponse,
|
||||
} from "@generated/anki/scheduler_pb";
|
||||
import type { DeckOptionsState } from "./lib";
|
||||
import SwitchRow from "$lib/components/SwitchRow.svelte";
|
||||
|
@ -177,6 +182,42 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
}
|
||||
}
|
||||
|
||||
async function workloadGraph(): Promise<void> {
|
||||
let resp: SimulateFsrsWorkloadResponse | undefined;
|
||||
updateRequest();
|
||||
try {
|
||||
await runWithBackendProgress(
|
||||
async () => {
|
||||
simulating = true;
|
||||
resp = await simulateFsrsWorkload(simulateFsrsRequest);
|
||||
},
|
||||
() => {},
|
||||
);
|
||||
} finally {
|
||||
simulating = false;
|
||||
if (resp) {
|
||||
simulationNumber += 1;
|
||||
|
||||
points = points.concat(
|
||||
Object.entries(resp.memorized).map(([dr, v]) => ({
|
||||
x: parseInt(dr),
|
||||
timeCost: resp!.cost[dr],
|
||||
count: resp!.cost[dr] / v,
|
||||
memorized: v,
|
||||
label: simulationNumber,
|
||||
})),
|
||||
);
|
||||
|
||||
tableData = renderSimulationChart(
|
||||
svg as SVGElement,
|
||||
bounds,
|
||||
points,
|
||||
simulateSubgraph,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function clearSimulation() {
|
||||
points = points.filter((p) => p.label !== simulationNumber);
|
||||
simulationNumber = Math.max(0, simulationNumber - 1);
|
||||
|
@ -430,11 +471,19 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
</button>
|
||||
|
||||
<button
|
||||
class="btn {computing ? 'btn-warning' : 'btn-primary'}"
|
||||
disabled={computing}
|
||||
on:click={clearSimulation}
|
||||
class="btn {computing ? 'btn-warning' : 'btn-primary'}"
|
||||
disabled={computing}
|
||||
on:click={clearSimulation}
|
||||
>
|
||||
{tr.deckConfigClearLastSimulate()}
|
||||
{tr.deckConfigClearLastSimulate()}
|
||||
</button>
|
||||
|
||||
<button
|
||||
disabled={computing}
|
||||
class="btn {computing ? 'btn-warning' : 'btn-primary'}"
|
||||
on:click={workloadGraph}
|
||||
>
|
||||
Display Dr Workloads
|
||||
</button>
|
||||
|
||||
<button
|
||||
|
|
Loading…
Reference in a new issue