Skip to content

Commit

Permalink
include backlog cards in today in future due graph (#3379)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
jakeprobst and dae authored Nov 6, 2024
1 parent b4ae7ce commit 487b38b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion rslib/src/stats/graphs/future_due.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
16 changes: 13 additions & 3 deletions ts/routes/graphs/future-due.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 487b38b

Please sign in to comment.