From df0eb0451f28cb49970dd465ef937cb55897c20f Mon Sep 17 00:00:00 2001 From: Fred Boniface Date: Thu, 13 Jul 2023 20:36:12 +0100 Subject: [PATCH] Fix ECS PIS Code missing Signed-off-by: Fred Boniface --- src/configs/version.configs.js | 2 +- src/controllers/train.controllers.js | 2 +- src/services/trainService.services.js | 10 ++++++---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/configs/version.configs.js b/src/configs/version.configs.js index 81574c1..5f3d312 100644 --- a/src/configs/version.configs.js +++ b/src/configs/version.configs.js @@ -1,6 +1,6 @@ const version = { api: ['/api/v1/','/api/v2'], - app: '2023.7.6' + app: '2023.7.7' }; module.exports = version; \ No newline at end of file diff --git a/src/controllers/train.controllers.js b/src/controllers/train.controllers.js index 1022432..f85194f 100644 --- a/src/controllers/train.controllers.js +++ b/src/controllers/train.controllers.js @@ -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: diff --git a/src/services/trainService.services.js b/src/services/trainService.services.js index 5646f9d..25eb641 100644 --- a/src/services/trainService.services.js +++ b/src/services/trainService.services.js @@ -103,10 +103,12 @@ async function findByTrainUid(uid, date = new Date()) { let publicStops; if (pis.supported.includes(services[0]?.operator)) { publicStops = await getPublicStops(services[0]?.stops); - const pisCode = await pis.findByTiplocArray(publicStops); - services[0].pis = pisCode[0]?.code; - } else if ( services[0]?.operator === 'GW' && !publicStops.length) { - services[0].pis = '0015'; + 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]; }