# Project tracking (templater, metaedit, and dataview)

**URL:** <https://forum.obsidian.md/t/project-tracking-templater-metaedit-and-dataview/19103>\
**Category:** Workflows & Templates\
**Created:** [June 1, 2021, 7:36am UTC](https://forum.obsidian.md/t/project-tracking-templater-metaedit-and-dataview/19103 "2021-06-01T07:36:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mara-Li](https://forum.obsidian.md/user_avatar/forum.obsidian.md/mara-li/32/12591_2.png) [@Mara-Li](https://forum.obsidian.md/u/Mara-Li)\
**Post date:** [June 1, 2021, 7:36am UTC](https://forum.obsidian.md/t/project-tracking-templater-metaedit-and-dataview/19103/1 "2021-06-01T07:36:11Z")

</div>

[![](https://img.youtube.com/vi/UHc2u1K-kDs/maxresdefault.jpg "Obsidian - Following project") ](https://www.youtube.com/watch?v=UHc2u1K-kDs)

The other day, on the discord, I presented my “project tracker”, which allows me to almost automatically update a project according to the number of titles used and compare to a total.

So here is the tutorial to be able to do the same thing.

First of all, here is the frontmatter and the template of a new note :

```md
<%*
const title = tp.file.folder();
const line_start = await tp.system.prompt("Start:");
const nb = await tp.system.prompt("Number:");
const line_end = (parseInt(line_start) + parseInt(nb)) - 1
await tp.file.rename(`[${title}] ${line_start} - ${line_end} `);
_%>

---
nb_tot: <% `${nb}` %>
Journal: <% tp.file.folder() %>
line_start: <% `${line_start}` %>
line_end: <% `${line_end}` %>
date: <% tp.date.tomorrow("DD-MM-YYYY") %>
nb: <% tp.user.count(tp) %>
done: <% tp.user.check(tp, tp.frontmatter.nb, tp.frontmatter.nb_tot) %>

---

```

Every time I create a new file, it asks me for the start as well as the number that will be my final title total (the total).  
The date allows me to predict when I will do this “review”.

Finally, I use two JS scripts: `check` and `count` which are :

```js
function check(tp, nb, nb_tot) {
    if (nb >= nb_tot) {
        new Notice("🎉 Well done :D", 5000)
        return "✅"
    } else {
        if (nb === nb_tot/2 ) {
            new Notice ("Half! Keep Going 🦉", 5000)
        }
        new Notice (nb, 5000)
        return "❌"
    }
}
module.exports = check

```

```js
module.exports = (tp) => {
    return tp.file.content.split("\n").reduce((acc, line) => new RegExp(/^# /).test(line) ? acc + 1 : acc, 0);
}

```

- `check` allows me to automatically put ✅ or ❌ comparing the total number with the number that has been done, while informing me how many I have done & how many I have left.
- `count` allows you to calculate the number of titles.

After that, I use a templater command with the metaedit api which allows me to update my frontmatter using a simple command. Usually I use `shift + F2` (put through hotkey for templater).

The template is as follows:

```auto
<%*
const {update} = app.plugins.plugins["metaedit"].api;
const filePath = tp.file.path(true);
await update("nb", `${tp.user.count(tp)}`, filePath);
await update("done", `${tp.user.check(tp, tp.frontmatter.nb, tp.frontmatter.nb_tot)}`, filePath);
const nb_done = tp.user.count(tp)
%>

```

Finally, on an index (I use folder note for that), I use dataview :

```yaml
---
nb: /
Journal: ❌
done: ❌
nb_tot: 0
---

```

```button
name New file
type note(9. Master 1/Stage/Data/Re-Review/CCM 2010/Journal+Line, split) template
action Stage
templater true

```

^button-stage

# Total::

```js
	let totalDone = 0;
	for (const day of dv.pages('"9. Master 1/Stage/Data/Re-review/CCM 2010"')) {
		if (day.done === "❌") continue;
		totalDone += day.nb;
	}
	
let filled = ""

let gaugeText = " ";
let percent = 0;
const gaugeLength = 50
const completionPercentage = (totalDone / dv.current().Total)
const nbFilledCharacters = gaugeLength * completionPercentage

for (let i = 0 ; i < gaugeLength ; i++) {
	if (i < nbFilledCharacters) {
	gaugeText += """;
	percent += 1
	} 
		else gaugeText += "░";
		percent += 0
}
percent = percent *2
gaugeText += " ";
dv.paragraph("<h4 align="center">" + gaugeText + "<br>" + percent + "</h4>")

```

```js
dv.table(["File", "Date", "Article"], dv.pages('"9. Master 1/Stage/Data/Re-review/CCM 2010"').where(d => !d.Journal.includes("❌")).sort(d => d.date).sort(d => d.file.name).map(d => [d.file.link, d.date, d.nb, d.done]);

```

```js
let totalcheck = 0;
for (const d of dv.pages('"9. Master 1/Stage/Data/Re-review/CCM 2010"')) {
	totalcheck += d.nb_tot; 
}

	let totalDone = 0
	for (const day of dv.pages('"9. Master 1/Stage/Data/Re-review/CCM 2010"')) {
		if (day.done === "❌") continue;
		totalDone += day.nb;
	}
const remaining = dv.current().Total - totalDone

dv.paragraph("<h6 align="center\">Predicted: " + totalcheck + "<br> Remaining : " + remaining + "</h6>");

```

This gives:

 ![image](https://forum.obsidian.md/uploads/default/original/2X/9/9e145e01f77ffb24f5a507ab0e6fba13f9a15998.png)

Don’t forget to change the folder!

---

<div class="post-metadata">

**Author:** ![Aonto](https://forum.obsidian.md/user_avatar/forum.obsidian.md/aonto/32/479_2.png) [@Aonto](https://forum.obsidian.md/u/Aonto)\
**Post date:** [June 4, 2021, 7:38am UTC](https://forum.obsidian.md/t/project-tracking-templater-metaedit-and-dataview/19103/2 "2021-06-04T07:38:25Z")

</div>

Thanks for so detailed post!

---

<div class="post-metadata">

**Author:** ![fred1357944](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/f/b3f665/32.png) [@fred1357944](https://forum.obsidian.md/u/fred1357944)\
**Post date:** [July 5, 2021, 4:06am UTC](https://forum.obsidian.md/t/project-tracking-templater-metaedit-and-dataview/19103/3 "2021-07-05T04:06:42Z")

</div>

sorry I don’t know why it keep pop out templator parsing error aborting…  
is there any setting I didn’t done?  
Thanks for this sharing!
