mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-29 08:00:06 +00:00
fix(tours): open a saved ski tour as saved and keep what its router planned
A saved ski tour now opens with the line, heights, time, build and planned legs it was saved with, read from the place this device keeps, and nothing is asked of the piste router until a point, an option or the discipline changes. Opened offline, while TREK Places is down or with piste routing switched off, it no longer turns every leg straight, and a rename saves the planned tour as it was. A kept line whose length is not the tour's is another save's, and the tour is planned afresh. - the save names the legs the router planned (ski_planned_legs, checked against the tour's own legs); get_tour_plan reports each leg routed or drawn from them instead of from the build alone, a tour that names none counting as planned only with the router's time - copies keep ski_options in every path: in the trip, taken over, kept in a collection and made from one (collection_tours gets the column in the same unshipped migration) - the route summary shows the data build, the km of runs, the height skied down on them and the lift rides, and the credit the server sends in place of a fixed one; a tour opened as saved says so - answers refused while piste routing is off, or planned on an older kept copy, are not remembered, so they are asked again later - terrain heights between known ones are filled in one walk along the line - i18n: five summary keys in all 27 locales
This commit is contained in:
@@ -46,6 +46,7 @@ export class CollectionTours {
|
||||
source_trip_title!: string;
|
||||
source_tour_name!: string;
|
||||
created_at!: string & Opt;
|
||||
ski_options?: string | null;
|
||||
tourTypeRef!: Ref<TourTypes>;
|
||||
savedByRef?: Ref<Users> | null;
|
||||
}
|
||||
@@ -93,7 +94,10 @@ export const CollectionToursSchema = defineEntity({
|
||||
source_trip_title: p.text(),
|
||||
source_tour_name: p.text(),
|
||||
created_at: p.type(DbTimestampType).defaultRaw(`CURRENT_TIMESTAMP`),
|
||||
tourTypeRef: () => p.manyToOne(TourTypes).ref().joinColumn('tour_type').hidden().index('idx_collection_tours_tour_type'),
|
||||
savedByRef: () => p.manyToOne(Users).ref().joinColumn('saved_by').nullable().hidden().index('idx_collection_tours_saved_by'),
|
||||
ski_options: p.text().nullable(),
|
||||
tourTypeRef: () =>
|
||||
p.manyToOne(TourTypes).ref().joinColumn('tour_type').hidden().index('idx_collection_tours_tour_type'),
|
||||
savedByRef: () =>
|
||||
p.manyToOne(Users).ref().joinColumn('saved_by').nullable().hidden().index('idx_collection_tours_saved_by'),
|
||||
},
|
||||
});
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
paddleLockSchema,
|
||||
paddleRegionBoundarySchema,
|
||||
paddleRegionGraphStatsSchema,
|
||||
skiPlannedLegsSchema,
|
||||
skiRouteOptionsSchema,
|
||||
tourChangeSchema,
|
||||
tourFixedLegSchema,
|
||||
@@ -197,12 +198,20 @@ export const TOUR_HIKING_PREFERENCES: JsonColumn<HikingPreferences | null> = {
|
||||
export interface TourSkiRoute {
|
||||
options: SkiRouteOptions;
|
||||
build: string | null;
|
||||
/** The legs the piste router planned, by the index of the point each starts at; absent where the save did not say. */
|
||||
planned_legs?: number[];
|
||||
}
|
||||
|
||||
const tourSkiRouteSchema = z.object({
|
||||
options: skiRouteOptionsSchema,
|
||||
build: z.string().nullable(),
|
||||
planned_legs: skiPlannedLegsSchema.optional(),
|
||||
});
|
||||
|
||||
/** A ski tour's piste router options. A broken row reads as none, and the planner offers the defaults. */
|
||||
export const TOUR_SKI_ROUTE: JsonColumn<TourSkiRoute | null> = {
|
||||
column: 'tours.ski_options',
|
||||
schema: z.object({ options: skiRouteOptionsSchema, build: z.string().nullable() }).nullable(),
|
||||
schema: tourSkiRouteSchema.nullable(),
|
||||
fallback: () => null,
|
||||
};
|
||||
|
||||
|
||||
@@ -41,4 +41,5 @@ export interface CollectionToursTable {
|
||||
source_trip_title: string;
|
||||
source_tour_name: string;
|
||||
created_at: InsertOptional<string>;
|
||||
ski_options: InsertOptional<string | null>;
|
||||
}
|
||||
|
||||
+3
-1
@@ -7,12 +7,14 @@ import { Migration } from '@mikro-orm/migrations';
|
||||
* (`TOUR_SKI_ROUTE` in json-columns.ts). NULL for every other type, for an
|
||||
* imported track and for a ski tour saved before the router. Reopened, the
|
||||
* tour is planned with the same options, and a newer build of the piste data
|
||||
* can be offered instead of applied.
|
||||
* can be offered instead of applied. A tour kept in a collection keeps the
|
||||
* same column, so a copy made from it is planned as the tour it was saved from.
|
||||
*/
|
||||
export class Migration20200101046140_a_ski_tour_keeps_its_piste_router_options extends Migration {
|
||||
override name = 'Migration20200101046140_a_ski_tour_keeps_its_piste_router_options';
|
||||
|
||||
override up(): void {
|
||||
this.addSql('ALTER TABLE tours ADD COLUMN ski_options TEXT');
|
||||
this.addSql('ALTER TABLE collection_tours ADD COLUMN ski_options TEXT');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,6 +36,8 @@ export interface CollectionTourRow {
|
||||
run_pace_seconds_per_km: number | null;
|
||||
ski_discipline: string | null;
|
||||
ski_technique: string | null;
|
||||
/** A ski tour's piste router options and build as JSON text, as the tour it was saved from kept them. */
|
||||
ski_options: string | null;
|
||||
boat_type: string | null;
|
||||
water_context: string | null;
|
||||
paddle_speed_kmh: number | null;
|
||||
|
||||
Reference in New Issue
Block a user