This is what I have done so far:
```dataviewjs
const tasks = [
{ id: 1, name: "keywords", completed: false,
subtasks: [
{text: "L1", lim: 1, completed: false},
{text: "L2", lim: 5, completed: false},
{text: "L3", lim: 10, completed: false},
{text: "L4", lim: 20, completed: false},
]},
{ id: 2, name: "terms", completed: false,
subtasks: [
{text: "L1", lim: 1, completed: false},
{text: "L2", lim: 3, completed: false},
{text: "L3", lim: 9, completed: false},
]},
{ id: 3, name: "citations", completed: false,
subtasks: [
{text: "L1", lim: 1, completed: false},
{text: "L2", lim: 2, completed: false},
{text: "L3", lim: 4, completed: false},
{text: "L4", lim: 8, completed: false},
{text: "L5", lim: 16, completed: false},
]},
{ id: 4, name: "figures", completed: false,
subtasks: [
{text: "L1", lim: 1, completed: false},
{text: "L2", lim: 3, completed: false},
{text: "L3", lim: 9, completed: false},
]},
{ id: 5, name: "critique", completed: false,
subtasks: [
{text: "L1", lim: 1, completed: false},
{text: "L2", lim: 3, completed: false},
{text: "L3", lim: 7, completed: false},
]},
{ id: 6, name: "highlights", completed: false,
subtasks: [
{text: "L1", lim: 1, completed: false},
{text: "L2", lim: 3, completed: false},
{text: "L3", lim: 7, completed: false},
]},
{ id: 7, name: "!equation", completed: false,
subtasks: [
{text: "L1", lim: 1, completed: false},
{text: "L2", lim: 2, completed: false},
]},
{ id: 8, name: "!schematic", completed: false,
subtasks: [
{text: "L1", lim: 3, completed: false},
{text: "L2", lim: 5, completed: false},
]},
{ id: 9, name: "Code available", completed: false,
subtasks: [
{text: "L0", lim: 1, completed: false},
]},
{ id: 10, name: "Running DevContainer", completed: false,
subtasks: [
{text: "L0", lim: 1, completed: false},
]},
];
// Check if a task is completed
const isTaskCompleted = (taskId) => {
const task = tasks.find((t) => t.id === taskId);
return task ? task.completed : false;
};
// Check if a subtask is completed
const isSubtaskCompleted = (taskId, taskValue) => {
const task = tasks.find((t) => t.id === taskId);
task.subtasks.forEach(st => {
if (taskValue >= st.lim) st.completed = true
})
return task
};
let taskId;
let taskValue;
taskId = 1;
taskValue = 1;
console.log(taskId, isSubtaskCompleted(taskId, taskValue))
taskId = 2;
taskValue = 1;
console.log(taskId, isSubtaskCompleted(taskId, taskValue))
taskId = 3;
taskValue = 1;
console.log(taskId, isSubtaskCompleted(taskId, taskValue))
taskId = 4;
taskValue = 3;
console.log(taskId, isSubtaskCompleted(taskId, taskValue))
taskId = 5;
taskValue = 2;
console.log(taskId, isSubtaskCompleted(taskId, taskValue))
taskId = 6;
taskValue = 1;
console.log(taskId, isSubtaskCompleted(taskId, taskValue))
taskId = 8;
taskValue = 2;
console.log(taskId, isSubtaskCompleted(taskId, taskValue))
taskId = 9;
taskValue = 1;
console.log(taskId, isSubtaskCompleted(taskId, taskValue))
var nSubtasks = tasks
.map(t => t.subtasks.length )
.reduce( (accum, st) => accum + st, 0);
var nStCompleted = tasks
.map(t => t.subtasks
.filter(st => st.completed))
.filter(task => task.length !== 0).flat().length
// dv.span(tasks)
dv.table(["id", "criteria", "Level", "completed"],
tasks.map(p => [
p.id,
p.name,
p.subtasks.map(q => q.text),
p.subtasks.map(q => q.completed ? "🟢" : "🔴")
]
)
)
dv.span("Progress: ")
dv.span((nStCompleted / nSubtasks * 100).toFixed(2))
dv.span("%")
```
This allows me to get a percentage of completion as I progress reviewing papers. The more useful or important snippets I exttact, the most valuable the paper is. It works like some sort of ranking.
There is a couple of remaining things I wanted to ask for help: how to remove the bullet from the list in Level and completed.
This will allow me to (i) insert the javascript snippet as a view; (ii) insert the view in all the paper notes (more than 350); (iii) be able to modify the view and automatically be reflected in all the notes.