Skip to content

Commit 6f666a2

Browse files
committed
fix: apply coderabbit suggestion
1 parent 942926b commit 6f666a2

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

app/utils/charts.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,9 @@ export function computeLineChartAnalysis(values: Array<number | null>): LineChar
306306

307307
let trend: LineChartAnalysis['interpretation']['trend'] = 'undefined'
308308

309-
if (rSquared !== null) {
309+
if (standardDeviation === 0) {
310+
trend = 'none'
311+
} else if (rSquared !== null) {
310312
if (rSquared > 0.75) {
311313
trend = 'strong'
312314
} else if (rSquared > 0.4) {

test/unit/app/utils/charts.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ describe('computeLineChartAnalysis', () => {
449449
expect(result.slope).toBe(0)
450450
expect(result.rSquared).toBeNull()
451451
expect(result.interpretation.volatility).toBe('undefined')
452-
expect(result.interpretation.trend).toBe('undefined')
452+
expect(result.interpretation.trend).toBe('none')
453453
})
454454

455455
it('handles two values where the first value is 0', () => {
@@ -521,7 +521,7 @@ describe('computeLineChartAnalysis', () => {
521521
expect(result.mean).toBe(5)
522522
expect(result.standardDeviation).toBe(0)
523523
expect(result.rSquared).toBeNull()
524-
expect(result.interpretation.trend).toBe('undefined')
524+
expect(result.interpretation.trend).toBe('none')
525525
})
526526

527527
it('handles nulls within a perfect linear trend using original indexes', () => {
@@ -666,6 +666,6 @@ describe('computeLineChartAnalysis', () => {
666666

667667
const undefinedTrend = computeLineChartAnalysis([0, 0, 0, 0])
668668
expect(undefinedTrend.rSquared).toBeNull()
669-
expect(undefinedTrend.interpretation.trend).toBe('undefined')
669+
expect(undefinedTrend.interpretation.trend).toBe('none')
670670
})
671671
})

0 commit comments

Comments
 (0)