From b61851e12284fbffa167acc08b94ada6a6936c22 Mon Sep 17 00:00:00 2001 From: Fred Boniface Date: Mon, 11 Sep 2023 20:47:38 +0100 Subject: [PATCH] Fix handling in cases where there are no NRCC messages Signed-off-by: Fred Boniface --- src/utils/translators/ldb/staffStation.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/utils/translators/ldb/staffStation.ts b/src/utils/translators/ldb/staffStation.ts index f910734..adc8ad8 100644 --- a/src/utils/translators/ldb/staffStation.ts +++ b/src/utils/translators/ldb/staffStation.ts @@ -34,10 +34,15 @@ export function transform(input: any): StaffLdb | null { } function transformDateTime(input: string): Date { + console.log("Transform Date Time Running") return new Date(input); } function transformNrcc(input: any): NrccMessage[] | undefined { + console.log("Transform Nrcc Running") + if (input === undefined) { + return input + } let output: NrccMessage[] = []; let messages = input; if (!Array.isArray(input?.message)) { @@ -57,6 +62,7 @@ function transformNrcc(input: any): NrccMessage[] | undefined { } function transformTrainServices(input: any): TrainServices[] { + console.log("Transform Train Services Running") let services: any = input?.service; let output: TrainServices[] = []; if (services === undefined) { @@ -98,6 +104,7 @@ function transformTrainServices(input: any): TrainServices[] { } function transformLocation(input: any): ServiceLocation[] { + console.log("Transform Location Running") let output: ServiceLocation[] = []; let locations: any[] = input.location; if (!Array.isArray(input.location)) { @@ -116,6 +123,7 @@ function transformLocation(input: any): ServiceLocation[] { } export function calculateLength(input: any): number | undefined { + console.log("Calculate Length Running") let length: number; if (input?.length) { length = input.length; @@ -129,6 +137,7 @@ export function calculateLength(input: any): number | undefined { } function transformUnspecifiedDateTime(input: string): Date | undefined { + console.log("Transform Unspecified Date Time Running") if (!input) { return undefined; }