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
This commit is contained in:
Damien Elmes 2022-04-25 14:14:08 +10:00
parent 39192e1698
commit dfa8d50a9d

View file

@ -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 {