summaryrefslogtreecommitdiff
path: root/templates/Summary.md
blob: 83e4436c2621ec5fad4e11df1557bf7358b0ba38 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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~~~~")
})
```