Here is a script to calculate the average duration of the work intervals:
{
let tot = 0, n = 0
for (let iv of activity.icu_intervals) {
if (iv.type !== 'WORK') continue
//console.log("iv.elapsed_time", iv.elapsed_time)
tot += iv.elapsed_time
++n
}
n > 0 ? tot/n : null
}
You can uncomment the console.log to see each value.
You can use the “Convert” option on the custom activity field to display the seconds value as time.
Here are all the fields available on each interval: Server side data model for scripts