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
This commit is contained in:
Damien Elmes 2023-10-21 11:59:50 +10:00
parent 7942487593
commit 3bfd828503
2 changed files with 9 additions and 7 deletions

View File

@ -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;
}
}

View File

@ -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<number, number>): 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 });
}