Bugfix: PIS Codes not being found for GW services

Signed-off-by: Fred Boniface <fred@fjla.uk>
This commit is contained in:
Fred Boniface 2023-07-11 22:33:10 +01:00
parent e79985cb5a
commit 24b882ce5f
2 changed files with 5 additions and 5 deletions

View File

@ -1,6 +1,6 @@
const version = {
api: ['/api/v1/','/api/v2'],
app: '2023.7.3'
app: '2023.7.4'
};
module.exports = version;

View File

@ -20,14 +20,14 @@ async function findByHeadcodeToday(headcode) {
let trainData = await parseTrains(queryData);
let preparedData = [];
for (let trainService in trainData) {
if (trainData /* CONDTION NEEDS CHANGIN WHEN DBMAN UPDATED /*pis.supported.includes(trainData?.operator)*/) {
if (pis.supported.includes(trainData[trainService]['operator'])) {
// Search for PIS Code for each service
const tiplocList = await getPublicStops(trainData[trainService]['stops']);
//console.log(tiplocList.length); console.log(tiplocList);
if (tiplocList.length) {
const pisDetail = await pis.findByTiplocArray(tiplocList);
trainData[trainService]['pis'] = pisDetail?.[0]?.['code'] ?? 'None';
} else {
} else if (trainData[trainService]['operator'] === 'GW') {
trainData[trainService]['pis'] = '0015'; // Not in Service code
// '0015' is a string becuase 0015 is not a valid number..
}
@ -61,13 +61,13 @@ async function findByHeadcode(date, headcode) {
let preparedData = [];
for (let trainService in trainData) {
// Search for PIS Code for each service if supported by PIS services
if (pis.supported.includes(trainData?.operator)) {
if (pis.supported.includes(trainData[trainService]['operator'])) {
const tiplocList = await getPublicStops(trainData[trainService]['stops']);
//console.log(tiplocList.length); console.log(tiplocList);
if (tiplocList.length) {
const pisDetail = await pis.findByTiplocArray(tiplocList);
trainData[trainService]['pis'] = pisDetail?.[0]?.['code'] ?? 'None';
} else if (trainData?.operator === 'GW' && !tiplocList.length) {
} else if (trainData[trainService]['operator'] === 'GW' && !tiplocList.length) {
// Not in Service code - for GWR Only
trainData[trainService]['pis'] = '0015';
}