Skip to content

Commit 67b83ba

Browse files
committed
Refactor outerValue and comparisoOuterValue to value and comparisonValue
1 parent 83708f2 commit 67b83ba

3 files changed

Lines changed: 16 additions & 16 deletions

File tree

assets/js/dashboard/stats/graph/main-graph-data.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@ describe(`${getRelativeChange.name}`, () => {
4343
const np = (numericValue = 0) => ({
4444
mainSeriesDefined: true,
4545
numericValue,
46-
outerValue: numericValue,
46+
value: numericValue,
4747
isPartial: false,
4848
timeLabel: ''
4949
})
5050
const p = (numericValue = 0) => ({
5151
mainSeriesDefined: true,
5252
numericValue,
53-
outerValue: numericValue,
53+
value: numericValue,
5454
isPartial: true,
5555
timeLabel: ''
5656
})

assets/js/dashboard/stats/graph/main-graph-data.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import {
1414
* Extracts the numeric values for the series when they are wrapped.
1515
*
1616
* In the same single loop, for the sake of efficiency, it determines
17-
* - the maximum y value (used for scaling the graph),
1817
* - the start and end labels of both series (used for generating appropriate X axis labels),
1918
*
2019
*/
@@ -78,16 +77,15 @@ export const remapAndFillData = ({
7877

7978
lastTimeLabel = timeLabel
8079

81-
const outerValue =
80+
const value =
8281
indexOfResult !== null
8382
? getValue(data.results[indexOfResult]!)
8483
: getValue({ metrics: data.meta.empty_metrics })
85-
const numericValue = getNumericValue(outerValue)
8684

8785
mainSeries = {
8886
mainSeriesDefined,
89-
numericValue,
90-
outerValue,
87+
value,
88+
numericValue: getNumericValue(value),
9189
isPartial,
9290
timeLabel
9391
}
@@ -102,16 +100,15 @@ export const remapAndFillData = ({
102100

103101
lastComparisonTimeLabel = comparisonTimeLabel
104102

105-
const comparisonOuterValue =
103+
const comparisonValue =
106104
indexOfComparisonResult !== null
107105
? getValue(data.comparison_results[indexOfComparisonResult]!)
108106
: getValue({ metrics: data.meta.empty_metrics })
109-
const comparisonNumericValue = getNumericValue(comparisonOuterValue)
110107

111108
comparisonSeries = {
112109
comparisonSeriesDefined,
113-
comparisonNumericValue,
114-
comparisonOuterValue,
110+
comparisonValue,
111+
comparisonNumericValue: getNumericValue(comparisonValue),
115112
comparisonTimeLabel
116113
}
117114
} else {
@@ -123,7 +120,10 @@ export const remapAndFillData = ({
123120
comparisonSeries.comparisonSeriesDefined &&
124121
change === null
125122
) {
126-
change = getChange(mainSeries.numericValue, comparisonSeries.comparisonNumericValue)
123+
change = getChange(
124+
mainSeries.numericValue,
125+
comparisonSeries.comparisonNumericValue
126+
)
127127
}
128128

129129
return {
@@ -228,7 +228,7 @@ type MainSeriesValue =
228228
| {
229229
mainSeriesDefined: true
230230
numericValue: number
231-
outerValue: RevenueMetricValue | number
231+
value: RevenueMetricValue | number
232232
isPartial: boolean
233233
timeLabel: string
234234
}
@@ -240,6 +240,6 @@ type ComparisonSeriesValue =
240240
| {
241241
comparisonSeriesDefined: true
242242
comparisonNumericValue: number
243-
comparisonOuterValue: RevenueMetricValue | number
243+
comparisonValue: RevenueMetricValue | number
244244
comparisonTimeLabel: string
245245
}

assets/js/dashboard/stats/graph/main-graph.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ const MainGraphTooltip = ({
370370
</div>
371371
</div>
372372
<div className="font-bold whitespace-nowrap">
373-
{getFormattedValue(datum.outerValue)}
373+
{getFormattedValue(datum.value)}
374374
</div>
375375
</div>
376376
)}
@@ -393,7 +393,7 @@ const MainGraphTooltip = ({
393393
</div>
394394
<div className="font-bold whitespace-nowrap">
395395
{' '}
396-
{getFormattedValue(datum.comparisonOuterValue)}
396+
{getFormattedValue(datum.comparisonValue)}
397397
</div>
398398
</div>
399399
)}

0 commit comments

Comments
 (0)