From 90614736f2a0c556f31eca5361b3c032f5f309f6 Mon Sep 17 00:00:00 2001 From: Martin Kagamino Lehoux Date: Thu, 24 Sep 2026 08:37:33 +0200 Subject: Match official climbs against their recorded sample MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit An official climb matched on endpoint coordinates alone. On a loop ridden the other way the route meets the climb's top before its bottom, so pairing each start with the first end inside its lap window credited a 5.9 km passage as the 850 m Chemin de la Tour Pey Blanc, and a 49 km one on another ride. Climbs now keep the sample of the segment they were created from: the recorded length and elevation gain of the selected route points, captured by the ride detail and preview handlers and stored NOT NULL. Matching takes the whole route and drops any candidate outside ±50% of that sample on either axis, and attempts are refreshed by upsert and prune so re-analyzing a ride keeps the recorded-at stamp of the passages that survive. The backfill leaves the web package: backfill.Run recomputes ride values then official climb attempts as a single `go run . backfill` command (climbs-backfill is gone), rideanalysis owns the attempt snapshot, and the mountain-pass loading margin is shared. Applied to the stored rides it stamps 78 samples, drops the four bogus attempts and leaves ride 800 with its three Pont Rout passages. --- ...260925000000_official_climb_sample_not_null.sql | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 db/migrations/20260925000000_official_climb_sample_not_null.sql (limited to 'db/migrations/20260925000000_official_climb_sample_not_null.sql') diff --git a/db/migrations/20260925000000_official_climb_sample_not_null.sql b/db/migrations/20260925000000_official_climb_sample_not_null.sql new file mode 100644 index 0000000..a3f80c2 --- /dev/null +++ b/db/migrations/20260925000000_official_climb_sample_not_null.sql @@ -0,0 +1,38 @@ +-- Every climb carries its segment sample, so the columns stop being optional; SQLite cannot alter nullability, hence the rebuild (it fails loudly on a missing sample). +-- migrate:up transaction:false +PRAGMA foreign_keys=OFF; +CREATE TABLE official_climbs_rebuild ( + id integer primary key, + name text not null, + start_latitude real not null, + start_longitude real not null, + end_latitude real not null, + end_longitude real not null, + created_at text not null default (strftime('%Y-%m-%dT%H:%M:%SZ', 'now')), + updated_at text not null default (strftime('%Y-%m-%dT%H:%M:%SZ', 'now')), + sample_distance_m real not null, + sample_elevation_gain_m real not null +); +INSERT INTO official_climbs_rebuild (id, name, start_latitude, start_longitude, end_latitude, end_longitude, created_at, updated_at, sample_distance_m, sample_elevation_gain_m) +SELECT id, name, start_latitude, start_longitude, end_latitude, end_longitude, created_at, updated_at, sample_distance_m, sample_elevation_gain_m FROM official_climbs; +DROP TABLE official_climbs; +ALTER TABLE official_climbs_rebuild RENAME TO official_climbs; + +-- migrate:down transaction:false +PRAGMA foreign_keys=OFF; +CREATE TABLE official_climbs_rebuild ( + id integer primary key, + name text not null, + start_latitude real not null, + start_longitude real not null, + end_latitude real not null, + end_longitude real not null, + created_at text not null default (strftime('%Y-%m-%dT%H:%M:%SZ', 'now')), + updated_at text not null default (strftime('%Y-%m-%dT%H:%M:%SZ', 'now')), + sample_distance_m real, + sample_elevation_gain_m real +); +INSERT INTO official_climbs_rebuild (id, name, start_latitude, start_longitude, end_latitude, end_longitude, created_at, updated_at, sample_distance_m, sample_elevation_gain_m) +SELECT id, name, start_latitude, start_longitude, end_latitude, end_longitude, created_at, updated_at, sample_distance_m, sample_elevation_gain_m FROM official_climbs; +DROP TABLE official_climbs; +ALTER TABLE official_climbs_rebuild RENAME TO official_climbs; -- cgit v1.3