Skip to content

Commit

Permalink
Merge pull request #150 from Financial-Times/fix-datapoints-undefined
Browse files Browse the repository at this point in the history
Fix Cannot read property ‘datapoints’ of undefined
  • Loading branch information
fenglish committed Jun 14, 2021
2 parents dbf6743 + 3065d0c commit da0c48a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/checks/graphiteSpike.check.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,13 @@ class GraphiteSpikeCheck extends Check {
.then(fetchres.json)
])

const baselineValue = baseline[0].datapoints[0][0]
const sampleValue = sample[0].datapoints[0][0]
const baselineValue = baseline[0] && baseline[0].datapoints[0][0]
const sampleValue = sample[0] && sample[0].datapoints[0][0]

const data = this.normalize({
sample: sample[0] && !Object.is(sampleValue, null) ? sampleValue : 0,
sample: sampleValue && !Object.is(sampleValue, null) ? sampleValue : 0,
// baseline should not be allowed to be smaller than one as it is use as a divisor
baseline: baseline[0] && !Object.is(baselineValue, null) && !Object.is(baselineValue, 0) ? baselineValue : 1
baseline: baselineValue && !Object.is(baselineValue, null) && !Object.is(baselineValue, 0) ? baselineValue : 1
});

const ok = this.direction === 'up'
Expand Down

0 comments on commit da0c48a

Please sign in to comment.