mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-28 05:30:55 +00:00
Package boarding station updates
This commit is contained in:
@@ -216,7 +216,26 @@ export class PackagesService {
|
||||
},
|
||||
});
|
||||
if (!pkg) throw new NotFoundException('Package not found');
|
||||
return { ...pkg, journeyType: pkg.returnScheduleId ? 'ROUND_TRIP' : 'ONE_WAY' };
|
||||
|
||||
// Fetch live route stops so the departure station dropdown always reflects
|
||||
// the current route definition, not stale TripStopTime snapshots.
|
||||
let routeStops: { sequence: number; station: any }[] = [];
|
||||
if (pkg.outboundSchedule.routeId) {
|
||||
const stops = await this.prisma.routeStop.findMany({
|
||||
where: { routeId: pkg.outboundSchedule.routeId },
|
||||
orderBy: { sequence: 'asc' },
|
||||
});
|
||||
const stationIds = stops.map((s) => s.stationId);
|
||||
const stations = await this.prisma.station.findMany({ where: { id: { in: stationIds } } });
|
||||
const stationMap = Object.fromEntries(stations.map((s) => [s.id, s]));
|
||||
routeStops = stops.map((s) => ({ sequence: s.sequence, station: stationMap[s.stationId] }));
|
||||
}
|
||||
|
||||
return {
|
||||
...pkg,
|
||||
journeyType: pkg.returnScheduleId ? 'ROUND_TRIP' : 'ONE_WAY',
|
||||
outboundSchedule: { ...pkg.outboundSchedule, routeStops },
|
||||
};
|
||||
}
|
||||
|
||||
create(dto: CreatePackageDto) {
|
||||
|
||||
Reference in New Issue
Block a user