From babd4563dcad38efe9780c9a4597353f1ba20979 Mon Sep 17 00:00:00 2001 From: Fred Boniface Date: Fri, 28 Jul 2023 21:09:44 +0100 Subject: [PATCH] Add mq-client to the 'Versions' response Signed-off-by: Fred Boniface --- src/controllers/stats.controllers.js | 2 +- src/services/stats.services.js | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/controllers/stats.controllers.js b/src/controllers/stats.controllers.js index 95e4786..2c1d81f 100644 --- a/src/controllers/stats.controllers.js +++ b/src/controllers/stats.controllers.js @@ -12,7 +12,7 @@ async function get(req, res, next) { // API V1 async function versions(req, res, next) { // API v2 try { - res.json(await stat.versions()); + res.json(await stat.getVersions()); } catch (err) { console.error('Controller Error', err); err.status = 500; diff --git a/src/services/stats.services.js b/src/services/stats.services.js index b2c9eab..26b881d 100644 --- a/src/services/stats.services.js +++ b/src/services/stats.services.js @@ -40,17 +40,16 @@ async function hits(){ return out; } -async function versions() { - log.out('statsServices.versions: Fetching versions', 'info'); - const versions = await db.query('meta', {target: 'versions'}); - let data = { - backend: '', - 'db-manager': '', - 'mq-subscriber': '', - }; - data.backend = vers.app; - data['db-manager'] = versions[0]['dbmanager']; - return data; +async function getVersions() { + log.out('statsServices.getVersions: Fetching versions', 'info'); + const dbMan = await db.query('versions', {target: 'dbmanager'}); + const mqClt = await db.query('versions', {target: 'mq-client'}); + const data = { + 'backend': vers.app, + 'db-manager': dbMan[0]?.['version'] || '', + 'mq-client': mqClt[0]?.['version'] || '', + } + return data } async function statistics() { @@ -133,5 +132,6 @@ async function statistics() { module.exports = { hits, versions, - statistics + statistics, + getVersions }; \ No newline at end of file