Way to perform sum on live query examples

Hi, I want to live query the time I spent today on specific thing, and I want to do it in live query. Basically I need to sum the duration attribute from paragraphs like below:

[duration:30] [time:08:34:27] #timetrack search time tracking app #distraction

[duration:50] [time:08:55:18] #timetrack hiddenbrain #listen-podcast #psychology

[duration:42] [time:09:37:01] #timetrack commute #listen-podcast #commute

I found that you can get sum from template but that is one time output, I need to update it everytime I add my entry. I wonder if it is possible to do this on live query. The one with template is here: Counting trip expenses

Update:

I’m wrong to assume that template is not live queried. Actually it works as a live queried example. It’s just amazing how extensible the Silverbullet is, even for people like me with minimal JavaScript knowledge. Shout out to zef’s great work.

Below is the outcome:

And you can see this code snippet that works for the case I showed above:

**Time spent on Main Task**: {{sum("duration", {paragraph where page = @page.name and tags = 'timetrack' and tags = 'main'})}} mins

**Other**: {{sum("duration", {paragraph where page = @page.name and tags = 'timetrack' and tags != 'main'})}} mins

I hope this would help people who wants to achieve similar functionalities in the future.

3 Likes