Hello, thank you for your reply. I will try and clarify things.
As I mentioned, dataview adds the completion date to completed tasks. As I read in this thread this information can be called by
TASK
WHERE completion != null AND completion = date("YOUR DATE IN FORMAT YYYY-MM-DD")
also it does suggest the following query for pages with completed tasks of the last 7 days:
TABLE WITHOUT ID (filter(file.tasks, (t) => t.completion >= date(now) - dur(7 d)).text) AS " task completed this week"
WHERE file.tasks.completed AND file.tasks.annotated
However I think the main issue are the days where 0 tasks were completed. Since I would like the information to be displayed in a chart, if these days are not accounted for, the line graph would be misleading. The only way I can figure how these days could be included is by having a loop compare the list of tasks with the list of dates and count the instances.
So a script would need to generate a list of the last 7 days, I assume something like
function getLastSevenDays() {
const dates = [];
for (let i = 6; i >= 0; i--) {
const date = new Date();
date.setDate(date.getDate() - i);
dates.push(date.toISOString().split('T')[0]); // Get date in yyyy-mm-dd format
}
return dates;
}
And then compare that list with the list of the tasks and count the instances:
// Function to compare List A with List B and create List C
function compareDates(listA, listB) {
const listC = [];
for (const dateA of listA) {
let count = 0;
for (const dateB of listB) {
if (dateA === dateB) {
count++;
}
}
listC.push(count);
}
return listC;
}
I just have trouble putting it all together. I will look into your suggestion and see how far I can get. My bigges hinderance is that I dont really know how to debug these javascript functions step by step. Guess I have some reading to do.