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
case CardQueue.Learn:
case CardQueue.DayLearn:
case CardQueue.PreviewRepeat:
young += 1;
break;
case CardQueue.Suspended:

View file

@ -21,16 +21,18 @@ export interface 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[])
.filter(
(c) =>
// reviews
[CardQueue.Review, CardQueue.DayLearn].includes(c.queue) ||
// or learning cards due today
(c.queue == CardQueue.Learn && c.due < data.nextDayAtSecs)
(isLearning(c.queue) && c.due < data.nextDayAtSecs)
)
.map((c) => {
if (c.queue == CardQueue.Learn) {
if (isLearning(c.queue)) {
return 0;
} else {
// - testing just odue fails on day 1