mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-29 16:10:07 +00:00
feat(atlas): flight routes, travellers and badges on the server
- GET /api/addons/atlas/flights folds the user's flight bookings into routes, airports and totals for the globe's arcs (#1369, #2642). - GET /api/addons/atlas/people answers the Atlas side of other travellers on the instance: counts, visited countries and earned badges, never trips, places or dates. A user hides themselves with the atlas_hidden setting; the admin switch atlas_compare_enabled turns it off for all. - shared/src/atlas/atlas-badges.ts holds the badge rules, computed from the data a user already has, so nothing is stored. - MCP: list_atlas_flight_routes, list_atlas_badges, list_atlas_travellers.
This commit is contained in:
@@ -269,6 +269,37 @@ export class ReservationEndpointsRepository extends TrekRepository<ReservationEn
|
||||
.execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* The Atlas flight map: every endpoint of the user's own flight bookings with
|
||||
* its airport and date, in leg order. Same ownership rule as
|
||||
* {@link listOwnedFlightLegsForUser} (TRAVELER_OWNS), cancelled flights left out.
|
||||
*/
|
||||
async listOwnedFlightRoutesForUser(userId: number): Promise<
|
||||
{
|
||||
reservation_id: number;
|
||||
sequence: number;
|
||||
code: string | null;
|
||||
name: string;
|
||||
lat: number;
|
||||
lng: number;
|
||||
local_date: string | null;
|
||||
}[]
|
||||
> {
|
||||
return await this.kysely<TravelerOwnedEndpointsWithTripsKyselyDB>()
|
||||
.selectFrom('reservation_endpoints as re')
|
||||
.innerJoin('reservations as r', 'r.id', 're.reservation_id')
|
||||
.innerJoin('trips as t', 't.id', 'r.trip_id')
|
||||
.leftJoin('trip_members as tm', (join) => join.onRef('tm.trip_id', '=', 't.id').on('tm.user_id', '=', userId))
|
||||
.select(['re.reservation_id', 're.sequence', 're.code', 're.name', 're.lat', 're.lng', 're.local_date'])
|
||||
.where((eb) => eb.or([eb('t.user_id', '=', userId), eb('tm.user_id', 'is not', null)]))
|
||||
.where('r.type', '=', 'flight')
|
||||
.where('r.status', '!=', 'cancelled')
|
||||
.where((eb) => travelerOwnsExpr(eb, userId))
|
||||
.orderBy('re.reservation_id', 'asc')
|
||||
.orderBy('re.sequence', 'asc')
|
||||
.execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* RPL6 (`RoadtripPlanService.withTerminals`) — `SELECT e.reservation_id,
|
||||
* e.role, e.sequence, e.name, e.code, e.lat, e.lng FROM
|
||||
|
||||
Reference in New Issue
Block a user