add cron jobs and aslo

This commit is contained in:
Marshal
2026-06-11 20:59:19 +00:00
parent cde3e462ba
commit 132f2150a8
18 changed files with 787 additions and 54 deletions

View File

@@ -113,6 +113,7 @@ export class TrainSchedulingService {
originStationId: query.originStationId,
destinationStationId: query.destinationStationId,
schedulingStatus: query.schedulingStatus,
trainScheduleId: query.trainScheduleId,
});
return { count: bookings.length, items: bookings.map((b) => this.mapEligibleBooking(b)) };
}
@@ -272,6 +273,20 @@ export class TrainSchedulingService {
throw new BadRequestException('Schedule has no train set');
}
// Batch parity: a schedule may only allocate bookings that targeted it. This mirrors
// the automatic fill, which only pulls bookings whose train_schedule_id is this schedule.
if (dto.bookingIds.length) {
const targeted = await this.bookingsRepository.findByIdsForScheduling(dto.bookingIds);
const stray = targeted.filter((b) => b.trainScheduleId !== scheduleId);
if (stray.length) {
throw new BadRequestException(
`These bookings are not assigned to this schedule: ${stray
.map((b) => b.reference ?? b.id)
.join(', ')}`,
);
}
}
const previewDto = {
bookingIds: dto.bookingIds,
scheduleDate: schedule.scheduledDepartureDate.toISOString(),