From 005b4b7147bea441d9dadeed3929b9b1e454a4d9 Mon Sep 17 00:00:00 2001 From: Luc Mcgrady Date: Sun, 13 Jul 2025 10:24:17 +0100 Subject: [PATCH] slapdash frontend --- qt/aqt/mediasrv.py | 1 + ts/routes/deck-options/SimulatorModal.svelte | 59 ++++++++++++++++++-- 2 files changed, 55 insertions(+), 5 deletions(-) diff --git a/qt/aqt/mediasrv.py b/qt/aqt/mediasrv.py index f08be4cef..d1d55e232 100644 --- a/qt/aqt/mediasrv.py +++ b/qt/aqt/mediasrv.py @@ -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", diff --git a/ts/routes/deck-options/SimulatorModal.svelte b/ts/routes/deck-options/SimulatorModal.svelte index c9bf2b702..c456ed32b 100644 --- a/ts/routes/deck-options/SimulatorModal.svelte +++ b/ts/routes/deck-options/SimulatorModal.svelte @@ -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 { + 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 + +