Passenger reports filter updates

This commit is contained in:
Stephanos A
2026-07-19 17:21:44 +03:00
parent 3e76069e9f
commit 80915f94ec
2 changed files with 84 additions and 34 deletions

View File

@@ -311,11 +311,20 @@ export class ReportsService {
booking: { status: { in: ['CONFIRMED', 'BOARDED'] } },
},
include: {
booking: { select: { bookingRef: true, status: true } },
booking: { select: { bookingRef: true, status: true, originStationId: true, destinationStationId: true } },
seat: { include: { coach: { select: { number: true, coachType: { select: { name: true } } } } } },
},
orderBy: [{ seat: { coach: { number: 'asc' } } }],
});
const stationIds = [...new Set(
seats.flatMap(bs => [bs.booking.originStationId, bs.booking.destinationStationId]).filter(Boolean) as string[]
)];
const stations = stationIds.length
? await this.prisma.station.findMany({ where: { id: { in: stationIds } }, select: { id: true, name: true } })
: [];
const stationMap = new Map(stations.map(s => [s.id, s.name]));
return seats.map(bs => ({
bookingRef: bs.booking.bookingRef,
bookingStatus: bs.booking.status,
@@ -328,6 +337,8 @@ export class ReportsService {
seatLabel: bs.seatLabelSnapshot,
coachNumber: bs.seat?.coach?.number ?? null,
coachType: (bs.seat?.coach as any)?.coachType?.name ?? null,
origin: bs.booking.originStationId ? (stationMap.get(bs.booking.originStationId) ?? null) : null,
destination: bs.booking.destinationStationId ? (stationMap.get(bs.booking.destinationStationId) ?? null) : null,
}));
}