handle preview cards in graphs

This commit is contained in:
Damien Elmes 2020-07-30 09:10:40 +10:00
parent a1866e72fd
commit f9891da076
2 changed files with 5 additions and 2 deletions

View file

@ -46,6 +46,7 @@ export function gatherData(data: pb.BackendProto.GraphsOut, i18n: I18n): GraphDa
// young falls through // young falls through
case CardQueue.Learn: case CardQueue.Learn:
case CardQueue.DayLearn: case CardQueue.DayLearn:
case CardQueue.PreviewRepeat:
young += 1; young += 1;
break; break;
case CardQueue.Suspended: case CardQueue.Suspended:

View file

@ -21,16 +21,18 @@ export interface GraphData {
} }
export function gatherData(data: pb.BackendProto.GraphsOut): GraphData { export function gatherData(data: pb.BackendProto.GraphsOut): GraphData {
const isLearning = (queue: number): boolean =>
[CardQueue.Learn, CardQueue.PreviewRepeat].includes(queue);
const due = (data.cards as pb.BackendProto.Card[]) const due = (data.cards as pb.BackendProto.Card[])
.filter( .filter(
(c) => (c) =>
// reviews // reviews
[CardQueue.Review, CardQueue.DayLearn].includes(c.queue) || [CardQueue.Review, CardQueue.DayLearn].includes(c.queue) ||
// or learning cards due today // or learning cards due today
(c.queue == CardQueue.Learn && c.due < data.nextDayAtSecs) (isLearning(c.queue) && c.due < data.nextDayAtSecs)
) )
.map((c) => { .map((c) => {
if (c.queue == CardQueue.Learn) { if (isLearning(c.queue)) {
return 0; return 0;
} else { } else {
// - testing just odue fails on day 1 // - testing just odue fails on day 1