Dataviewjs estimated end time from sum of task duration

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()


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 = ( + 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 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.

Stumbled across this, which I expect is the answer:

in particular, + dv.duration('3 days'))

replacing dv.current() with (moment().format('YYYY-MM-DD') gives me a result, albeit not a human friendly one, but I suppose it could be shifted with a little more work.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.