From 077aa1700fbcaf3f499c2178e0e58e89ae9dcaf8 Mon Sep 17 00:00:00 2001 From: Martin Kagamino Lehoux Date: Fri, 25 Sep 2026 08:46:58 +0200 Subject: 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. --- official_climb/attempt_test.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'official_climb/attempt_test.go') 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) -- cgit v1.3