Display backlog learn cards correctly in FutureDue graph

* now they are shown as due in the past
* before that they were always displayed as due today
This commit is contained in:
Henrik Giesel 2021-01-07 14:43:34 +01:00
parent ae410fac24
commit 2d22b09cd8

View file

@ -23,31 +23,38 @@ export interface GraphData {
} }
export function gatherData(data: pb.BackendProto.GraphsOut): GraphData { export function gatherData(data: pb.BackendProto.GraphsOut): GraphData {
const isLearning = (queue: number): boolean => const isLearning = (card: pb.BackendProto.Card): boolean =>
[CardQueue.Learn, CardQueue.PreviewRepeat].includes(queue); [CardQueue.Learn, CardQueue.PreviewRepeat].includes(card.queue);
let haveBacklog = false; let haveBacklog = false;
const due = (data.cards as pb.BackendProto.Card[]) const due = (data.cards as pb.BackendProto.Card[])
.filter( .filter((c: pb.BackendProto.Card) => {
(c) => // reviews
// reviews return (
[CardQueue.Review, CardQueue.DayLearn].includes(c.queue) || [CardQueue.Review, CardQueue.DayLearn].includes(c.queue) ||
// or learning cards due today // or learning cards
(isLearning(c.queue) && c.due < data.nextDayAtSecs) isLearning(c)
) );
.map((c) => { })
if (isLearning(c.queue)) { .map((c: pb.BackendProto.Card) => {
return 0; let dueDay: number;
if (isLearning(c)) {
const offset = c.due - data.nextDayAtSecs
dueDay = Math.floor(offset / 86_400) + 1;
} else { } else {
// - testing just odue fails on day 1 // - testing just odue fails on day 1
// - testing just odid fails on lapsed cards that // - testing just odid fails on lapsed cards that
// have due calculated at regraduation time // have due calculated at regraduation time
const due = c.originalDeckId && c.originalDue ? c.originalDue : c.due; const due = c.originalDeckId && c.originalDue ? c.originalDue : c.due;
const dueDay = due - data.daysElapsed; dueDay = due - data.daysElapsed;
if (dueDay < 0) {
haveBacklog = true;
}
return dueDay;
} }
haveBacklog = haveBacklog || dueDay < 0;
return dueDay
}); });
const dueCounts = rollup( const dueCounts = rollup(