From 757db4cabab88f692b7dc3ee06e9e3b7b0c58cf7 Mon Sep 17 00:00:00 2001 From: Benjamin Chausse Date: Thu, 31 Oct 2024 16:16:59 -0400 Subject: chp2 continues --- templates/Summary.md | 41 +++++++++++++++++++++++++++++++++++++++++ templates/Timesheet-Template.md | 30 ++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 templates/Summary.md create mode 100644 templates/Timesheet-Template.md (limited to 'templates') diff --git a/templates/Summary.md b/templates/Summary.md new file mode 100644 index 0000000..83e4436 --- /dev/null +++ b/templates/Summary.md @@ -0,0 +1,41 @@ +```dataviewjs +const folder = "Path/To/Base" +const groups = await dv.query(` + list WITHOUT id file.folder + FROM "${folder}" + WHERE any(hours) +`) +const groupList = [ + ...new Set(groups.value.values) +] + +groupList.forEach(async (group) => { + const result = await dv.query(` + TABLE WITHOUT id file.link AS "${group.replace(folder + "/", "")}", sum(hours) AS "Hours", + project AS "Project", file.name + FROM "${group}" + `) + + if (result.successful) { + const values = result.value.values + const headers = result.value.headers.slice(0, -1); + dv.table( + headers, + values.map(r => { + if (!Array.isArray(r[2])) { + r[2] = [r[2]] + } + + return [ + r[0], r[1], // Keep these as is + [ + r[3], + ...new Set(r[2]) + ] + ] + }) + ) + } else + dv.paragraph("~~~~\n" + result.error + "\n~~~~") +}) +``` \ No newline at end of file diff --git a/templates/Timesheet-Template.md b/templates/Timesheet-Template.md new file mode 100644 index 0000000..bc4933d --- /dev/null +++ b/templates/Timesheet-Template.md @@ -0,0 +1,30 @@ +Hours: `= sum(this.hours)` + +## Saturday - [hours:: 0] + +## Sunday - [hours:: 0] + +## Monday - [hours:: 0] + +### (project:: PROJECT-0000) +- note 1 + +## Tuesday - [hours:: 0] + +### (project:: PROJECT-0000) +- note 1 + +## Wednesday - [hours:: 0] + +### (project:: PROJECT-0000) +- note 1 + +## Thursday - [hours:: 0] + +### (project:: PROJECT-0000) +- note 1 + +## Friday - [hours:: 0] + +### (project:: PROJECT-0000) +- note 1 \ No newline at end of file -- cgit v1.2.3