Prepare 'trainSerice.services' for TS migration

Signed-off-by: Fred Boniface <fred@fjla.uk>
This commit is contained in:
Fred Boniface 2023-11-30 09:32:07 +00:00
parent acf8c5760e
commit ab09455c96

View File

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