Compare commits

...

4 Commits

Author SHA1 Message Date
Fred Boniface b61851e122 Fix handling in cases where there are no NRCC messages
Signed-off-by: Fred Boniface <fred@fjla.uk>
2023-09-11 20:47:38 +01:00
Fred Boniface c1a5ce1fe9 Add test data for station boards that do not contain any NRCC messages
Signed-off-by: Fred Boniface <fred@fjla.uk>
2023-09-11 20:47:24 +01:00
Fred Boniface c7ea029c11 Fix bug where query function returned empty array
Signed-off-by: Fred Boniface <fred@fjla.uk>
2023-09-11 20:47:04 +01:00
Fred Boniface ac24cb571e Improve spacing of email template
Signed-off-by: Fred Boniface <fred@fjla.uk>
2023-09-11 20:46:39 +01:00
5 changed files with 96 additions and 5 deletions

View File

@ -54,15 +54,16 @@
<h1>Register for OwlBoard</h1>
<br />
<p>
Use the link below or scan the barcode to register for OwlBoard
(Staff Version)
Tap the button to register this device, or scan the barcode with another device.
</p>
<br />
<a
href="https://owlboard.info/more/reg/submit?key=>>ACCESSCODE<<"
id="button"
>Register</a
>Register this device</a
>
<br /><br /><br />
<p>Or scan with the device you want to register</p>
<br />
<img
src="https://barcodes.fjla.uk/generate?type=aztec&text=https%3A%2F%2Fowlboard.info%2Fmore%2Freg%2Fsubmit%3Fkey%3D>>ACCESSCODE<<"

View File

@ -24,8 +24,9 @@ async function query(collection, query, returnId = false) {
log.out(`dbAccess.query: Running Query: ${JSON.stringify(query)}`, "info");
increment(collection);
log.out("dbAccess.query: Query response:");
console.log(await qcursor.toArray());
return await qcursor.toArray();
let result = await qcursor.toArray();
console.log(result);
return result;
}
async function queryProject(collection, query, projection) {

View File

@ -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;
}

View File

@ -53,4 +53,51 @@ export const inputs: any[] = [
},
},
},
{
GetBoardResult: {
generatedAt: "2023-08-01T20:37:05.559123+01:00",
locationName: "Railway Station",
crs: "RLY",
stationManager: "Network Rail",
stationManagerCode: "RT",
isTruncated: "true",
trainServices: {
service: [
{
rid: "202308017159276",
uid: "G59276",
trainid: "1M83",
sdd: "2023-08-01",
operator: "CrossCountry",
operatorCode: "XC",
sta: "2023-08-01T20:24:00",
ata: "2023-08-01T20:27:22",
arrivalType: "Actual",
std: "2023-08-01T20:35:00",
etd: "2023-08-01T20:35:00",
departureType: "Estimated",
departureSource: "Darwin",
platform: "5",
length: "10",
origin: {
location: {
locationName: "Plymouth",
crs: "PLY",
tiploc: "PLYMTH",
},
},
destination: {
location: {
locationName: "Birmingham New Street",
crs: "BHM",
tiploc: "BHAMNWS",
},
},
category: "XX",
activities: "T",
},
],
},
},
},
];

View File

@ -45,4 +45,37 @@ export const outputs: StaffLdb[] = [
busServices: [],
ferryServices: [],
},
{
generatedAt: expect.any(Date),
locationName: "Railway Station",
stationManagerCode: "RT",
trainServices: [
{
rid: "202308017159276",
uid: "G59276",
trainid: "1M83",
operatorCode: "XC",
sta: expect.any(Date),
ata: expect.any(Date),
arrivalType: "Actual",
std: expect.any(Date),
etd: expect.any(Date),
departureType: "Estimated",
platform: "5",
length: 10,
origin: [
{
tiploc: "PLYMTH",
},
],
destination: [
{
tiploc: "BHAMNWS",
},
],
},
],
busServices: [],
ferryServices: [],
},
];