From 9607ebce7597a18555a8ddee40d6a0be8682cc3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivar=20Conradi=20=C3=98sthus?= Date: Thu, 4 Feb 2021 15:54:29 +0100 Subject: [PATCH] fix: should wait for seen apps --- lib/routes/admin-api/metrics.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/routes/admin-api/metrics.js b/lib/routes/admin-api/metrics.js index 77b4cdf094..6f7805c0d6 100644 --- a/lib/routes/admin-api/metrics.js +++ b/lib/routes/admin-api/metrics.js @@ -27,23 +27,24 @@ class MetricsController extends Controller { this.get('/applications/:appName', this.getApplication); } - getSeenToggles(req, res) { - const seenAppToggles = this.metrics.getAppsWithToggles(); + async getSeenToggles(req, res) { + const seenAppToggles = await this.metrics.getAppsWithToggles(); res.json(seenAppToggles); } async getSeenApps(req, res) { - const seenApps = this.metrics.getSeenApps(); + const seenApps = await this.metrics.getSeenApps(); res.json(seenApps); } - getFeatureToggles(req, res) { - res.json(this.metrics.getTogglesMetrics()); + async getFeatureToggles(req, res) { + const toggles = await this.metrics.getTogglesMetrics(); + res.json(toggles); } - getFeatureToggle(req, res) { + async getFeatureToggle(req, res) { const { name } = req.params; - const data = this.metrics.getTogglesMetrics(); + const data = await this.metrics.getTogglesMetrics(); const lastHour = data.lastHour[name] || {}; const lastMinute = data.lastMinute[name] || {}; res.json({