TimetableAPI-Upgrade #64

Merged
fred.boniface merged 36 commits from TimetableAPI-Upgrade into main 2024-02-11 15:53:17 +00:00
1 changed files with 6 additions and 1 deletions
Showing only changes of commit ab09455c96 - Show all commits

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