From ab09455c96eff04865505bb4a1f2c5f05c1ef450 Mon Sep 17 00:00:00 2001 From: Fred Boniface Date: Thu, 30 Nov 2023 09:32:07 +0000 Subject: [PATCH] Prepare 'trainSerice.services' for TS migration Signed-off-by: Fred Boniface --- src/services/trainService.services.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/services/trainService.services.js b/src/services/trainService.services.js index 4eeb688..82a6014 100644 --- a/src/services/trainService.services.js +++ b/src/services/trainService.services.js @@ -4,6 +4,8 @@ const pis = require("../services/pis.services"); import { logger } from "../utils/logger.utils"; +// This function is deprecated and should no longer be used. +// It will be removed in a later version async function findByHeadcodeToday(headcode) { const sanitizedHeadcode = clean.removeNonAlphanumeric(headcode).toUpperCase(); logger.debug( @@ -39,6 +41,7 @@ async function findByHeadcodeToday(headcode) { return preparedData; } +// Finds a train by its headcode value async function findByHeadcode(date, headcode) { const sanitizedHeadcode = clean.removeNonAlphanumeric(headcode).toUpperCase(); logger.debug( @@ -82,6 +85,7 @@ async function findByHeadcode(date, headcode) { return await filteredData; } +// Finds a train by its trainUid value async function findByTrainUid(uid, date = new Date()) { let queryDate; if (date === "now") { @@ -153,6 +157,7 @@ async function parseTrains(data) { return parsedData; } +// Filters services based on their STP Indicator async function filterServices(data) { let stpIndicators = {}, filteredServices = []; @@ -180,7 +185,7 @@ async function filterServices(data) { stpIndicators[trainUid].hasP = true; } } - let preparedData; + for (const serviceDetail of data) { const trainUid = serviceDetail["trainUid"]; const thisStpIndicators = stpIndicators[trainUid];