What I’m trying to do
- There are a bunch of files having yaml property up as a link to the file “Organic chemistry”
- each one has a bunch of tasks in each
- trying to make a table with percentages to show how many are ticked off
current code
const currentNote = dv.current().file.link
const pages = dv.array(dv.pages())
const nav_list = []
for (let i = 0; i < pages.length; i++){
if (dv.array(pages[i].up).includes(currentNote)){
nav_list.push(pages[i].file.path)
}
}
let res = []
for (let i = 0; i < nav_list.length; i++){
let curr = dv.page(nav_list[i])
let total = curr.file.tasks.length
let comp = curr.file.tasks.filter(t => t.completed).length
let p = total > 0 ? ((comp/total)*100).toFixed(2) : 0
res.push({
name: curr.file.name,
total: total,
completed: comp,
percent: p
})
}
dv.table(["File Name", "Total Tasks", "Completed Tasks", "Completion %"],res.map(r => [r.name, r.total,r.completed,r.percent]))
output in live preview
output in reading mode
what is happening and how do I fix it