fix(tours): pair the tracks to take over in the tours domain, off the places list

This commit is contained in:
Maurice
2026-10-26 12:47:09 +01:00
parent 0313597b10
commit fd818050bd
7 changed files with 98 additions and 81 deletions
@@ -318,21 +318,6 @@ export class PlacesRepository extends TrekRepository<Places> {
return !!row;
}
/**
* The trip's tracks that are not tours: places with `route_geometry` and no
* `tours` row, oldest first. A GPX file imported before Tours existed (4.x)
* left its tracks like this, and the tour import takes one over by name
* instead of refusing it as a duplicate (#2810).
*/
async listTracksWithoutTour(trip_id: number): Promise<{ id: number; name: string; route_geometry: string }[]> {
return this.qb('p')
.leftJoin('p.tours', 't')
.select(['p.id', 'p.name', 'p.route_geometry'])
.where({ 'p.trip': trip_id, 'p.route_geometry': { $ne: null }, 't.place': null })
.orderBy({ 'p.id': 'asc' })
.execute<{ id: number; name: string; route_geometry: string }[]>('all', false);
}
/** PL19/PL21 — `DELETE FROM places WHERE id = ?`, unscoped: every caller proved trip access first. */
async deleteById(id: number): Promise<void> {
await this.nativeDelete({ id });