Skip to content

Commit

Permalink
include backlog cards in today in future due graph
Browse files Browse the repository at this point in the history
when backlog option is not checked
  • Loading branch information
jakeprobst committed Aug 23, 2024
1 parent a179da3 commit 8c9c71b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 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 @@ -26,7 +26,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
30 changes: 29 additions & 1 deletion ts/routes/graphs/future-due.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,34 @@ function makeQuery(start: number, end: number): string {
}
}

function getDueCounts(data, backlog) {
// if we're showing the backlog we don't need to do any extra processing
if (backlog) {
return data;
}

// if we're not showing the backlog, add those cards to what is due today
let backlog_count = data.entries().reduce((backlog_count, [days, count]) => {
if (days < 0) {
backlog_count += count;
}
return backlog_count;
}, 0);

var modified_data = new Map(
data.entries()
.filter(([day, count]) => {
if (day < 0) {
return false;
}
return true;
}),
);

modified_data.set(0, modified_data.get(0) + backlog_count);
return modified_data;
}

export function buildHistogram(
sourceData: GraphData,
range: GraphRange,
Expand All @@ -50,7 +78,7 @@ export function buildHistogram(
): FutureDueResponse {
const output = { histogramData: null, tableData: [] };
// get min/max
const data = sourceData.dueCounts;
const data = getDueCounts(sourceData.dueCounts, backlog);
if (!data) {
return output;
}
Expand Down

0 comments on commit 8c9c71b

Please sign in to comment.