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",
|
"evaluate_params_legacy",
|
||||||
"get_optimal_retention_parameters",
|
"get_optimal_retention_parameters",
|
||||||
"simulate_fsrs_review",
|
"simulate_fsrs_review",
|
||||||
|
"simulate_fsrs_workload",
|
||||||
# DeckConfigService
|
# DeckConfigService
|
||||||
"get_ignored_before_count",
|
"get_ignored_before_count",
|
||||||
"get_retention_workload",
|
"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 { SimulateSubgraph, type Point } from "../graphs/simulator";
|
||||||
import * as tr from "@generated/ftl";
|
import * as tr from "@generated/ftl";
|
||||||
import { renderSimulationChart } from "../graphs/simulator";
|
import { renderSimulationChart } from "../graphs/simulator";
|
||||||
import { computeOptimalRetention, simulateFsrsReview } from "@generated/backend";
|
import {
|
||||||
|
computeOptimalRetention,
|
||||||
|
simulateFsrsReview,
|
||||||
|
simulateFsrsWorkload,
|
||||||
|
} from "@generated/backend";
|
||||||
import { runWithBackendProgress } from "@tslib/progress";
|
import { runWithBackendProgress } from "@tslib/progress";
|
||||||
import type {
|
import type {
|
||||||
ComputeOptimalRetentionResponse,
|
ComputeOptimalRetentionResponse,
|
||||||
SimulateFsrsReviewRequest,
|
SimulateFsrsReviewRequest,
|
||||||
SimulateFsrsReviewResponse,
|
SimulateFsrsReviewResponse,
|
||||||
|
SimulateFsrsWorkloadResponse,
|
||||||
} from "@generated/anki/scheduler_pb";
|
} from "@generated/anki/scheduler_pb";
|
||||||
import type { DeckOptionsState } from "./lib";
|
import type { DeckOptionsState } from "./lib";
|
||||||
import SwitchRow from "$lib/components/SwitchRow.svelte";
|
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() {
|
function clearSimulation() {
|
||||||
points = points.filter((p) => p.label !== simulationNumber);
|
points = points.filter((p) => p.label !== simulationNumber);
|
||||||
simulationNumber = Math.max(0, simulationNumber - 1);
|
simulationNumber = Math.max(0, simulationNumber - 1);
|
||||||
|
@ -437,6 +478,14 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
{tr.deckConfigClearLastSimulate()}
|
{tr.deckConfigClearLastSimulate()}
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
<button
|
||||||
|
disabled={computing}
|
||||||
|
class="btn {computing ? 'btn-warning' : 'btn-primary'}"
|
||||||
|
on:click={workloadGraph}
|
||||||
|
>
|
||||||
|
Display Dr Workloads
|
||||||
|
</button>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
class="btn {computing ? 'btn-warning' : 'btn-primary'}"
|
class="btn {computing ? 'btn-warning' : 'btn-primary'}"
|
||||||
disabled={computing}
|
disabled={computing}
|
||||||
|
|
Loading…
Reference in a new issue