From 3bfd828503ecbf3cd76050c59825a9d8c744fd55 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Sat, 21 Oct 2023 11:59:50 +1000 Subject: [PATCH] Fix browser query not matching stats - Round instead of floor when binning - Account for rounding in search https://forums.ankiweb.net/t/anki-23-10-release-candidate/35967/4 --- rslib/src/stats/graphs/intervals.rs | 2 +- ts/graphs/intervals.ts | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/rslib/src/stats/graphs/intervals.rs b/rslib/src/stats/graphs/intervals.rs index b8a261ae0..25e686e6f 100644 --- a/rslib/src/stats/graphs/intervals.rs +++ b/rslib/src/stats/graphs/intervals.rs @@ -27,7 +27,7 @@ impl GraphsContext { if let Some(state) = &card.memory_state { *data .intervals - .entry(state.stability as u32) + .entry(state.stability.round() as u32) .or_insert_with(Default::default) += 1; } } diff --git a/ts/graphs/intervals.ts b/ts/graphs/intervals.ts index 8b9af80ca..1f69bfe54 100644 --- a/ts/graphs/intervals.ts +++ b/ts/graphs/intervals.ts @@ -67,15 +67,20 @@ export function intervalLabel( } } -function makeQuery(start: number, end: number): string { +function makeSm2Query(start: number, end: number): string { if (start === end) { return `"prop:ivl=${start}"`; } const fromQuery = `"prop:ivl>=${start}"`; const tillQuery = `"prop:ivl<=${end}"`; + return `${fromQuery} ${tillQuery}`; +} - return `${fromQuery} AND ${tillQuery}`; +function makeFsrsQuery(start: number, end: number): string { + const fromQuery = `"prop:s>=${start - 0.5}"`; + const tillQuery = `"prop:s<${end + 0.5}"`; + return `${fromQuery} ${tillQuery}`; } export function prepareIntervalData( @@ -156,10 +161,7 @@ export function prepareIntervalData( function onClick(bin: Bin): void { const start = bin.x0!; const end = bin.x1! - 1; - let query = makeQuery(start, end); - if (fsrs) { - query = query.replace(/ivl/g, "s"); - } + const query = (fsrs ? makeFsrsQuery : makeSm2Query)(start, end); dispatch("search", { query }); }