Merge pull request #5624 from influxdata/5623/flickering_test

fix(duration): repair relative computation of multiple ranges
pull/5626/head
Pavel Závora 2020-12-02 16:30:16 +01:00 committed by GitHub
commit e25eed1b37
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 5 deletions

View File

@ -17,6 +17,7 @@
### Other ### Other
1. [#5610](https://github.com/influxdata/chronograf/pull/5610): Upgrade golang to 1.15.5, node to 14 LTS. 1. [#5610](https://github.com/influxdata/chronograf/pull/5610): Upgrade golang to 1.15.5, node to 14 LTS.
1. [#5624](https://github.com/influxdata/chronograf/pull/5624): Repair possible millisecond differences in duration computation.
## v1.8.8 [2020-11-04] ## v1.8.8 [2020-11-04]

View File

@ -109,21 +109,21 @@ interface DurationBinaryExpression {
} }
export function allRangeTimes(ast: any): Array<[number, number]> { export function allRangeTimes(ast: any): Array<[number, number]> {
return findNodes(isRangeNode, ast).map(node => rangeTimes(ast, node)) const now = Date.now()
return findNodes(isRangeNode, ast).map(node => rangeTimes(ast, node, now))
} }
/* /*
Given a `range` call in an AST, reports the `start` and `stop` arguments the Given a `range` call in an AST, reports the `start` and `stop` arguments the
the call as absolute instants in time. If the `start` or `stop` argument is a the call as absolute instants in time. If the `start` or `stop` argument is a
relative duration literal, it is interpreted as relative to the current relative duration literal, it is interpreted as relative to now (`Date.now()`).
instant (`Date.now()`).
*/ */
function rangeTimes( function rangeTimes(
ast: any, ast: any,
rangeNode: RangeCallExpression rangeNode: RangeCallExpression,
now: number
): [number, number] { ): [number, number] {
const properties = rangeNode.arguments[0].properties const properties = rangeNode.arguments[0].properties
const now = Date.now()
// The `start` argument is required // The `start` argument is required
const startProperty = properties.find(p => p.key.name === 'start') const startProperty = properties.find(p => p.key.name === 'start')