Prepare 'trainSerice.services' for TS migration
Signed-off-by: Fred Boniface <fred@fjla.uk>
This commit is contained in:
parent
acf8c5760e
commit
ab09455c96
@ -4,6 +4,8 @@ const pis = require("../services/pis.services");
|
|||||||
|
|
||||||
import { logger } from "../utils/logger.utils";
|
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) {
|
async function findByHeadcodeToday(headcode) {
|
||||||
const sanitizedHeadcode = clean.removeNonAlphanumeric(headcode).toUpperCase();
|
const sanitizedHeadcode = clean.removeNonAlphanumeric(headcode).toUpperCase();
|
||||||
logger.debug(
|
logger.debug(
|
||||||
@ -39,6 +41,7 @@ async function findByHeadcodeToday(headcode) {
|
|||||||
return preparedData;
|
return preparedData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Finds a train by its headcode value
|
||||||
async function findByHeadcode(date, headcode) {
|
async function findByHeadcode(date, headcode) {
|
||||||
const sanitizedHeadcode = clean.removeNonAlphanumeric(headcode).toUpperCase();
|
const sanitizedHeadcode = clean.removeNonAlphanumeric(headcode).toUpperCase();
|
||||||
logger.debug(
|
logger.debug(
|
||||||
@ -82,6 +85,7 @@ async function findByHeadcode(date, headcode) {
|
|||||||
return await filteredData;
|
return await filteredData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Finds a train by its trainUid value
|
||||||
async function findByTrainUid(uid, date = new Date()) {
|
async function findByTrainUid(uid, date = new Date()) {
|
||||||
let queryDate;
|
let queryDate;
|
||||||
if (date === "now") {
|
if (date === "now") {
|
||||||
@ -153,6 +157,7 @@ async function parseTrains(data) {
|
|||||||
return parsedData;
|
return parsedData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Filters services based on their STP Indicator
|
||||||
async function filterServices(data) {
|
async function filterServices(data) {
|
||||||
let stpIndicators = {},
|
let stpIndicators = {},
|
||||||
filteredServices = [];
|
filteredServices = [];
|
||||||
@ -180,7 +185,7 @@ async function filterServices(data) {
|
|||||||
stpIndicators[trainUid].hasP = true;
|
stpIndicators[trainUid].hasP = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let preparedData;
|
|
||||||
for (const serviceDetail of data) {
|
for (const serviceDetail of data) {
|
||||||
const trainUid = serviceDetail["trainUid"];
|
const trainUid = serviceDetail["trainUid"];
|
||||||
const thisStpIndicators = stpIndicators[trainUid];
|
const thisStpIndicators = stpIndicators[trainUid];
|
||||||
|
Loading…
Reference in New Issue
Block a user