Fix ECS PIS Code missing

Signed-off-by: Fred Boniface <fred@fjla.uk>
This commit is contained in:
Fred Boniface 2023-07-13 20:36:12 +01:00
parent 6498f68bdf
commit df0eb0451f
3 changed files with 8 additions and 6 deletions

View File

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

View File

@ -30,7 +30,7 @@ async function get(req, res, next) {
case 'headcode':
res.json(await train.findByHeadcode(date, id));
break;
case 'trainuid':
case 'byTrainUid':
res.json(await train.findByTrainUid(id, date));
break;
default:

View File

@ -103,11 +103,13 @@ async function findByTrainUid(uid, date = new Date()) {
let publicStops;
if (pis.supported.includes(services[0]?.operator)) {
publicStops = await getPublicStops(services[0]?.stops);
if (publicStops.length) {
const pisCode = await pis.findByTiplocArray(publicStops);
services[0].pis = pisCode[0]?.code;
} else if ( services[0]?.operator === 'GW' && !publicStops.length) {
services[0].pis = '0015';
}
}
return services[0];
}