feat(tours): bike tours in the contract and on the server (BIK-01 to BIK-06, RTE-01)

A tour can be a bike tour with a routing profile (touring, road, gravel,
mtb), stored per tour by a new migration. The server grades the ways of a
mountain bike route from OpenStreetMap (mtb:scale) through one shared
Overpass client, offers CyclOSM behind its own admin switch, and exports a
bike tour's GPX with the activity of its profile. A hike's route choices
are now exactly the three the card names: steep climbs, steps and ferries.
This commit is contained in:
Maurice
2026-10-19 21:33:40 +02:00
parent c3229afcba
commit adcaca3c5f
126 changed files with 3112 additions and 237 deletions
+11
View File
@@ -38,6 +38,7 @@ export class Tours {
hiking_preferences?: string | null;
taken_over_from_trip_title?: string | null;
taken_over_from_tour_name?: string | null;
bike_profile?: TToursBikeProfile | null;
tourTypeRef!: Ref<TourTypes>;
tour_obstacle_reviews_collection = new Collection<TourObstacleReviews>(this);
tour_sources: Ref<TourSources> | null = null;
@@ -75,6 +76,15 @@ export const ToursPaddleLakeStyle = {
export type TToursPaddleLakeStyle = (typeof ToursPaddleLakeStyle)[keyof typeof ToursPaddleLakeStyle];
export const ToursBikeProfile = {
TOURING: 'touring',
ROAD: 'road',
GRAVEL: 'gravel',
MTB: 'mtb',
} as const;
export type TToursBikeProfile = (typeof ToursBikeProfile)[keyof typeof ToursBikeProfile];
export const ToursSchema = defineEntity({
class: Tours,
repository: () => ToursRepository,
@@ -116,6 +126,7 @@ export const ToursSchema = defineEntity({
hiking_preferences: p.text().nullable(),
taken_over_from_trip_title: p.text().nullable(),
taken_over_from_tour_name: p.text().nullable(),
bike_profile: p.enum(() => ToursBikeProfile).nullable(),
tourTypeRef: () => p.manyToOne(TourTypes).ref().joinColumn('tour_type').hidden().index('idx_tours_tour_type'),
tour_obstacle_reviews_collection: () => p.oneToMany(TourObstacleReviews).mappedBy('place').hidden(),
tour_sources: () => p.oneToOne(TourSources).ref().mappedBy('place').hidden(),
+1
View File
@@ -30,4 +30,5 @@ export interface ToursTable {
hiking_preferences: InsertOptional<string | null>;
taken_over_from_trip_title: InsertOptional<string | null>;
taken_over_from_tour_name: InsertOptional<string | null>;
bike_profile: InsertOptional<string | null>;
}
@@ -0,0 +1,18 @@
import { Migration } from '@mikro-orm/migrations';
/**
* BIK-01: a tour can be a bike tour. The `bike` key has been in `tour_types`,
* disabled, since every contract type was seeded; it is switched on here. The
* profile it is ridden on (touring, road, gravel, mtb) is a column of the
* tour, NULL on every other type, so no existing tour changes its meaning.
*/
export class Migration20200101045200_a_tour_can_be_ridden extends Migration {
override name = 'Migration20200101045200_a_tour_can_be_ridden';
override up(): void {
this.addSql(
"ALTER TABLE tours ADD COLUMN bike_profile TEXT CHECK (bike_profile IS NULL OR bike_profile IN ('touring', 'road', 'gravel', 'mtb'))",
);
this.addSql("UPDATE tour_types SET enabled = 1 WHERE key = 'bike'");
}
}
+11 -1
View File
@@ -2,7 +2,7 @@ import { type Tours, type TToursOrigin, ToursOrigin } from '../entities/Tours.en
import type { DB } from '../kysely/db';
import type { AssertRowKeys } from './_shared/rows';
import { TrekRepository } from './_shared/trek-repository';
import type { PaddleBoatType, PaddleLakeStyle, PaddleWaterContext } from '@trek/shared';
import type { BikeProfile, PaddleBoatType, PaddleLakeStyle, PaddleWaterContext } from '@trek/shared';
/**
* A tour as the Tours list and detail read it: the `tours` facet joined with
@@ -28,6 +28,8 @@ export interface TourListRow {
max_hiking_difficulty: number | null;
derived_from_place_id: number | null;
origin: string;
/** BIK-01: a bike tour's profile; NULL on every other type. */
bike_profile: string | null;
boat_type: string | null;
water_context: string | null;
paddle_speed_kmh: number | null;
@@ -92,6 +94,7 @@ export interface TourRow {
hiking_preferences: string | null;
taken_over_from_trip_title: string | null;
taken_over_from_tour_name: string | null;
bike_profile: string | null;
}
const _tourRowKeys: AssertRowKeys<TourRow, Tours> = true;
@@ -107,6 +110,8 @@ export interface TourInsert {
break_additional_minutes?: number | null;
match_confidence: number | null;
max_hiking_difficulty: number | null;
/** BIK-01: a bike tour's profile; left out, NULL. */
bike_profile?: BikeProfile | null;
/** A paddle tour's boat, water and chosen speed; left out, a hike's NULLs. */
boat_type?: PaddleBoatType | null;
water_context?: PaddleWaterContext | null;
@@ -123,6 +128,7 @@ export type TourUpdate = Omit<
| 'place_id'
| 'planned_duration_minutes'
| 'break_additional_minutes'
| 'bike_profile'
| 'boat_type'
| 'water_context'
| 'paddle_speed_kmh'
@@ -131,6 +137,7 @@ export type TourUpdate = Omit<
> & {
planned_duration_minutes?: number | null;
break_additional_minutes?: number | null;
bike_profile: BikeProfile | null;
boat_type: PaddleBoatType | null;
water_context: PaddleWaterContext | null;
paddle_speed_kmh: number | null;
@@ -232,6 +239,7 @@ export class ToursRepository extends TrekRepository<Tours> {
't.max_hiking_difficulty as max_hiking_difficulty',
't.derived_from_place_id as derived_from_place_id',
't.origin as origin',
't.bike_profile as bike_profile',
't.boat_type as boat_type',
't.water_context as water_context',
't.paddle_speed_kmh as paddle_speed_kmh',
@@ -585,6 +593,7 @@ export class ToursRepository extends TrekRepository<Tours> {
break_additional_minutes: input.break_additional_minutes ?? null,
match_confidence: input.match_confidence,
max_hiking_difficulty: input.max_hiking_difficulty,
bike_profile: input.bike_profile ?? null,
boat_type: input.boat_type ?? null,
water_context: input.water_context ?? null,
paddle_speed_kmh: input.paddle_speed_kmh ?? null,
@@ -669,6 +678,7 @@ export class ToursRepository extends TrekRepository<Tours> {
: {}),
match_confidence: input.match_confidence,
max_hiking_difficulty: input.max_hiking_difficulty,
bike_profile: input.bike_profile,
boat_type: input.boat_type,
water_context: input.water_context,
paddle_speed_kmh: input.paddle_speed_kmh,