From dfa8d50a9df47bebe322a1a293ef4a4b58ebde0d Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Mon, 25 Apr 2022 14:14:08 +1000 Subject: [PATCH] Fix due graph showing wrong date for review cards with resched off Since we are using the original due date instead of the current one, the learning check needs to be based on the card type, not its current queue. https://forums.ankiweb.net/t/anki-2-1-51-release-candidate/18942/22 --- ts/graphs/future-due.ts | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/ts/graphs/future-due.ts b/ts/graphs/future-due.ts index 801ac94e7..89801b9f7 100644 --- a/ts/graphs/future-due.ts +++ b/ts/graphs/future-due.ts @@ -16,7 +16,7 @@ import { sum, } from "d3"; -import { CardQueue } from "../lib/cards"; +import { CardType } from "../lib/cards"; import * as tr from "../lib/ftl"; import { localizedNumber } from "../lib/i18n"; import type { Cards, Stats } from "../lib/proto"; @@ -31,19 +31,15 @@ export interface GraphData { } export function gatherData(data: Stats.GraphsResponse): GraphData { - const isLearning = (card: Cards.Card): boolean => - [CardQueue.Learn, CardQueue.PreviewRepeat].includes(card.queue); - + const isIntradayLearning = (card: Cards.Card, due: number): boolean => { + return ( + [CardType.Learn, CardType.Relearn].includes(card.ctype) && + due > 1_000_000_000 + ); + }; let haveBacklog = false; const due = (data.cards as Cards.Card[]) - .filter((c: Cards.Card) => { - // reviews - return ( - [CardQueue.Review, CardQueue.DayLearn].includes(c.queue) || - // or learning cards - isLearning(c) - ); - }) + .filter((c: Cards.Card) => c.queue >= 0) .map((c: Cards.Card) => { // - testing just odue fails on day 1 // - testing just odid fails on lapsed cards that @@ -51,7 +47,7 @@ export function gatherData(data: Stats.GraphsResponse): GraphData { const due = c.originalDeckId && c.originalDue ? c.originalDue : c.due; let dueDay: number; - if (isLearning(c)) { + if (isIntradayLearning(c, due)) { const offset = due - data.nextDayAtSecs; dueDay = Math.floor(offset / 86_400) + 1; } else {