Skip to content

multiplyInterval - Multiply an interval by some number

The multiplyInterval function multiplies a given interval by a number. This allows for extrapolation over time.

NOTE: multiplyInterval works for both integer and decimal values.

Syntax

multiplyInterval(i: interval, factor: number): interval

Arguments

Name Type Required Description
i interval true The interval to be multiplied
factor number true The factor by which this interval should be multiplied

Example - Calculating overall time remaining

Consider the following document:

{
    "jobs_in_queue": 25,
    "time_per_job_seconds": 30
}

We can see that we have 25 remaining tasks, and each task will take around 30s. In order to calculate how long the overall wait time is, we can use multiplyInterval:

create overall_wait_time from toInterval(time_per_job_seconds, 's').multiplyInterval(jobs_in_queue)

This results in the following document:

{
    "jobs_in_queue": 25,
    "time_per_job_seconds": 30,
    "overall_wait_time": 12m30s
}