include backlog cards in today in future due graph (#3379)

* include backlog cards in today in future due graph

when backlog option is not checked

* Don't add the backlog to today when backlog disabled

---------

Co-authored-by: Damien Elmes <gpg@ankiweb.net>
This commit is contained in:
Jake Probst 2024-11-06 15:06:07 -08:00 committed by GitHub
parent b4ae7ce907
commit 487b38b06c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 4 deletions

View file

@ -32,7 +32,7 @@ impl GraphsContext {
}
// still want to filtered out buried cards that are due today
if due_day == 0 && matches!(c.queue, CardQueue::UserBuried | CardQueue::SchedBuried) {
if due_day <= 0 && matches!(c.queue, CardQueue::UserBuried | CardQueue::SchedBuried) {
continue;
}
have_backlog |= due_day < 0;

View file

@ -46,23 +46,33 @@ function makeQuery(start: number, end: number): string {
}
}
function withoutBacklog(data: Map<number, number>): Map<number, number> {
const map = new Map();
for (const [day, count] of data.entries()) {
if (day >= 0) {
map.set(day, count);
}
}
return map;
}
export function buildHistogram(
sourceData: GraphData,
range: GraphRange,
backlog: boolean,
includeBacklog: boolean,
dispatch: SearchDispatch,
browserLinksSupported: boolean,
): FutureDueResponse {
const output = { histogramData: null, tableData: [] };
// get min/max
const data = sourceData.dueCounts;
const data = includeBacklog ? sourceData.dueCounts : withoutBacklog(sourceData.dueCounts);
if (!data) {
return output;
}
const [xMinOrig, origXMax] = extent<number>(data.keys());
let xMin = xMinOrig;
if (!backlog) {
if (!includeBacklog) {
xMin = 0;
}
let xMax = origXMax;