Continuing the discussion from Dataview(JS): Summing task metadata:
I’ve searched (here and on dataview docs) trial-and-errored, but I can’t figure out how to add duration to the current time in dvjs.
What I’m trying to do
I’d like to build on this code to see an estimated end time as well as the estimated duration:
const notes = dv.pages("#project"); const tasks = notes.file.tasks.where(t => !t.completed && t.assigned && t.effort); const total = dv.luxon.Duration.fromMillis(tasks.effort.array().reduce((acc, val) => acc + val, 0)).shiftTo('minutes').toHuman() console.log(total) dv.span("**Global Effort**: " + total)
(I tweaked seanakabry2’s code to get just the minutes.)
I figured out how to make it one line, which is useful for
$= js queries, such as:
# 🎯 `$= dv.luxon.Duration.fromMillis(dv.current().file.tasks.where(t => !t.completed && t.dur).dur.array().reduce((acc, val) => acc + val, 0)).shiftTo('minutes').toHuman()`
Things I have tried
In the dataviewjs version, adding/tweaking to:
const finAT = (dv.date(today) + total) dv.span("**Global Effort**: " + total + " ~ " + finAT)
& other ways/attempts for the date (e.g.
moment().format('YYYY-MM-DD')), the duration, and the addition, e.g.
const finAT = dv.execute(date(today) + total) and a desperate stab at inserting
.plus.total in the luxon line. I don’t remember all the experiments, they mostly resulted in errors or null.
Closest results were something like
YYYY-MM-DD HH:MM19minutos, as if I were asking for a string. I’m guessing I’m not managing to get the date and the duration in compatible formats, or I’m using the wrong operator for adding.
I might try to experiment with some of the dataview code from that original thread, but I am wondering how to add date &/or time & durations in dataviewjs, as I figure it might have other uses.