Alright fixed the code: This actually creates an accurate streak count and lists by day:
dataviewjs
let pg = dv.current();
var habitArray = [
["Exercise"],
["Meditate"],
["Japanese"],
["Clean"]
];
const tasks = dv.current().file.tasks
.sort(t => dv.date(t.due))
.where(t => {
if(!t.text.includes("#habit")) {
return false;
}
for (let i = 0; i < habitArray.length; i++) {
if(t.text.includes(habitArray[i][0]))
{
if(t.completion) {
habitArray[i].push("✅");
} else {
habitArray[i].push("❌");
}
}
}
return true;
});
dv.table(
["Habit", "M","T","W","TH","F","SA","SU"],
habitArray);
NOTE: This code makes the assumption you have these tasks assigned for each of the seven dates in the week as the template example shows above.