Skip to content

Instantly share code, notes, and snippets.

@adrianogil
Created September 30, 2024 01:33
Show Gist options
  • Save adrianogil/6083bc5f8341f3f0909f96c8eb685958 to your computer and use it in GitHub Desktop.
Save adrianogil/6083bc5f8341f3f0909f96c8eb685958 to your computer and use it in GitHub Desktop.
A Dataview-based task management system for Obsidian

Tasks

    const tasks = await dv.pages('#task').where(t => t.task_status != "Dropped" && t.backlog != null && dv.io.normalize(t.backlog) == dv.current().file.path);
    let completedTasks = tasks.where(t => t.task_status == "Done");
    let donePercentage = parseInt((completedTasks.length / tasks.length) * 100);
    if (tasks.length == 0) donePercentage = 0;
    dv.span('Total: ' + completedTasks.length + '/' + tasks.length);
    dv.span('<br><br>')
    dv.span("<progress value='" + donePercentage + "' max='100'></progress>" + " " + donePercentage + "%")
TABLE
	task_status as "Status",
	("<progress value='" + round(100 * (length(filter(file.tasks, (t) => t.completed)) / length(file.tasks))) + "' max='100'></progress>" + " " + round(100 * (length(filter(file.tasks, (t) => t.completed)) / length(file.tasks))) + "%") as "Progress",
	priority as "Priority",
	deadline as "Deadline"
FROM #task 
WHERE backlog = [[{{title}}]] and task_status != "Done" and task_status != "Dropped"
SORT deadline ASC
SORT priority desc

WIP

ToDo

Done

TABLE
	task_status as "Status",
	priority as "Priority",
	deadline as "Deadline"
FROM #task 
WHERE backlog = [[{{title}}]] and task_status = "Done"

Dropped

TABLE
	task_status as "Status",
	priority as "Priority",
	deadline as "Deadline"
FROM #task 
WHERE backlog = [[{{title}}]] and task_status = "Dropped"

See also

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment