add review count graph

This commit is contained in:
Luc Mcgrady 2025-07-14 10:56:37 +01:00
parent fc89efb1d9
commit 9b838352e6
No known key found for this signature in database
GPG key ID: 4F3D7A0B17CC3D9C
4 changed files with 15 additions and 1 deletions

View file

@ -419,6 +419,7 @@ message SimulateFsrsReviewResponse {
message SimulateFsrsWorkloadResponse { message SimulateFsrsWorkloadResponse {
map<uint32, float> cost = 1; map<uint32, float> cost = 1;
map<uint32, float> memorized = 2; map<uint32, float> memorized = 2;
map<uint32, uint32> review_count = 3;
} }
message ComputeOptimalRetentionResponse { message ComputeOptimalRetentionResponse {

View file

@ -289,6 +289,7 @@ impl Collection {
( (
*result.memorized_cnt_per_day.last().unwrap_or(&0.), *result.memorized_cnt_per_day.last().unwrap_or(&0.),
result.cost_per_day.iter().sum::<f32>(), result.cost_per_day.iter().sum::<f32>(),
result.review_cnt_per_day.iter().sum::<usize>() as u32,
), ),
)) ))
}) })
@ -296,6 +297,7 @@ impl Collection {
Ok(SimulateFsrsWorkloadResponse { Ok(SimulateFsrsWorkloadResponse {
memorized: dr_workload.iter().map(|(k, v)| (*k, v.0)).collect(), memorized: dr_workload.iter().map(|(k, v)| (*k, v.0)).collect(),
cost: dr_workload.iter().map(|(k, v)| (*k, v.1)).collect(), cost: dr_workload.iter().map(|(k, v)| (*k, v.1)).collect(),
review_count: dr_workload.iter().map(|(k, v)| (*k, v.2)).collect(),
}) })
} }
} }

View file

@ -216,7 +216,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
x: parseInt(dr), x: parseInt(dr),
timeCost: resp!.cost[dr], timeCost: resp!.cost[dr],
memorized: v, memorized: v,
count: -1, count: resp!.reviewCount[dr],
label: workloadSimulationNumber, label: workloadSimulationNumber,
})), })),
); );
@ -617,6 +617,14 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
/> />
{"Ratio"} {"Ratio"}
</label> </label>
<label>
<input
type="radio"
value={SimulateWorkloadSubgraph.count}
bind:group={simulateWorkloadSubgraph}
/>
{tr.deckConfigFsrsSimulatorRadioCount()}
</label>
<label> <label>
<input <input
type="radio" type="radio"

View file

@ -40,6 +40,7 @@ export enum SimulateSubgraph {
export enum SimulateWorkloadSubgraph { export enum SimulateWorkloadSubgraph {
ratio, ratio,
time, time,
count,
memorized, memorized,
} }
@ -59,6 +60,7 @@ export function renderWorkloadChart(
const subgraph_data = ({ const subgraph_data = ({
[SimulateWorkloadSubgraph.ratio]: data.map(d => ({ ...d, y: d.timeCost / d.memorized })), [SimulateWorkloadSubgraph.ratio]: data.map(d => ({ ...d, y: d.timeCost / d.memorized })),
[SimulateWorkloadSubgraph.time]: data.map(d => ({ ...d, y: d.timeCost })), [SimulateWorkloadSubgraph.time]: data.map(d => ({ ...d, y: d.timeCost })),
[SimulateWorkloadSubgraph.count]: data.map(d => ({ ...d, y: d.count })),
[SimulateWorkloadSubgraph.memorized]: data.map(d => ({ ...d, y: d.memorized })), [SimulateWorkloadSubgraph.memorized]: data.map(d => ({ ...d, y: d.memorized })),
})[subgraph]; })[subgraph];
@ -69,6 +71,7 @@ export function renderWorkloadChart(
const formatY: (value: number) => string = ({ const formatY: (value: number) => string = ({
[SimulateWorkloadSubgraph.ratio]: (value: number) => `${timeSpan(value)} per memorized card`, [SimulateWorkloadSubgraph.ratio]: (value: number) => `${timeSpan(value)} per memorized card`,
[SimulateWorkloadSubgraph.time]: timeSpan, [SimulateWorkloadSubgraph.time]: timeSpan,
[SimulateWorkloadSubgraph.count]: (value: number) => tr.statisticsReviews({ reviews: Math.round(value) }),
[SimulateWorkloadSubgraph.memorized]: (value: number) => [SimulateWorkloadSubgraph.memorized]: (value: number) =>
tr.statisticsMemorized({ memorized: Math.round(value).toFixed(0) }), tr.statisticsMemorized({ memorized: Math.round(value).toFixed(0) }),
})[subgraph]; })[subgraph];