diff --git a/src/services/trainService.services.ts b/src/services/trainService.services.ts index d2b2df2..46d2e2e 100644 --- a/src/services/trainService.services.ts +++ b/src/services/trainService.services.ts @@ -38,6 +38,7 @@ export async function findByHeadcode( scheduleEndDate: { $gte: searchDate }, daysRun: { $in: [shortDay] }, }; + console.log(JSON.stringify(query)) const pipeline = getFindByHeadcodePipeline(query); const result: SimpleService[] = (await queryAggregate( diff --git a/src/utils/processors/timetable/timetableProcessor.utils.ts b/src/utils/processors/timetable/timetableProcessor.utils.ts index a75e1c5..849056c 100644 --- a/src/utils/processors/timetable/timetableProcessor.utils.ts +++ b/src/utils/processors/timetable/timetableProcessor.utils.ts @@ -36,6 +36,14 @@ export function formatTimetableDetail( } function formatStops(stops: Stop[]): OB_TrainTT_stopDetail[] { + if (!stops) { + return [] + } + + if (!stops.length) { + return [] + } + // Cleanly coerce Stop[] to OB_TrainTT_stopDetail[] const formattedStops: OB_TrainTT_stopDetail[] = [];