diff options
| author | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-09-25 08:46:58 +0200 |
|---|---|---|
| committer | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-09-25 08:46:58 +0200 |
| commit | 077aa1700fbcaf3f499c2178e0e58e89ae9dcaf8 (patch) | |
| tree | 020d0d8b34ab7b47cf551b50034c1e086a247af3 /official_climb/attempt_test.go | |
| parent | 90614736f2a0c556f31eca5361b3c032f5f309f6 (diff) | |
Chart power vs time for official climb attempts
Snapshot average power per attempt in a nullable average_power_w column (backfilled from stored rides), plot each powered attempt on the climb page as duration vs average watts with ride hover and click-through, and show avg power in the attempts table.
Diffstat (limited to 'official_climb/attempt_test.go')
| -rw-r--r-- | official_climb/attempt_test.go | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/official_climb/attempt_test.go b/official_climb/attempt_test.go index 8913807..e9d8b11 100644 --- a/official_climb/attempt_test.go +++ b/official_climb/attempt_test.go @@ -47,6 +47,7 @@ func withStartDate(startDate string) func(*rideInsert) { } func attemptFixture(rideID, climbID int64, occurrence int) official_climb.Attempt { + averagePowerW := 235.5 return official_climb.Attempt{ RideID: rideID, ClimbID: climbID, @@ -55,6 +56,7 @@ func attemptFixture(rideID, climbID int64, occurrence int) official_climb.Attemp ElevationGainM: 210, SlopePercent: 6.5, Cotacol: 84.2, + AveragePowerW: &averagePowerW, CotacolAlgoVersion: "v1", StartedAt: time.Date(2026, 9, 1, 10, 0, 0, 0, time.UTC), EndedAt: time.Date(2026, 9, 1, 10, 18, 30, 0, time.UTC), @@ -66,10 +68,12 @@ func TestReplaceRideAttemptsRoundTrip(t *testing.T) { created, err := official_climb.Create(db, official_climb.OfficialClimb{Name: "Col de Test", StartCoord: coord(43.6, 5.4), EndCoord: coord(43.62, 5.42), Sample: sampleFixture()}) require.NoError(t, err) rideID := insertRide(t, db) + withoutPower := attemptFixture(rideID, created.ID, 1) + withoutPower.AveragePowerW = nil require.NoError(t, official_climb.ReplaceRideAttempts(db, rideID, []official_climb.Attempt{ attemptFixture(rideID, created.ID, 0), - attemptFixture(rideID, created.ID, 1), + withoutPower, })) attempts, err := official_climb.AttemptsForClimb(db, created.ID) @@ -80,6 +84,9 @@ func TestReplaceRideAttemptsRoundTrip(t *testing.T) { assert.Equal(t, 3200.0, attempts[0].DistanceM) assert.Equal(t, "v1", attempts[0].CotacolAlgoVersion) assert.Equal(t, time.Date(2026, 9, 1, 10, 18, 30, 0, time.UTC), attempts[0].EndedAt) + require.NotNil(t, attempts[0].AveragePowerW) + assert.InDelta(t, 235.5, *attempts[0].AveragePowerW, 0.01) + assert.Nil(t, attempts[1].AveragePowerW, "a missing power meter must round-trip as null") rideAttempts, err := official_climb.AttemptsForRide(db, rideID) require.NoError(t, err) |
