1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-01 00:08:27 +01:00

fetch seen apps instead

This commit is contained in:
sveisvei 2016-12-05 13:53:53 +01:00
parent e9938d9a5b
commit 421a6413bf
2 changed files with 11 additions and 11 deletions

View File

@ -47,17 +47,17 @@ module.exports = class UnleashClientMetrics {
return this.apps[appName] ? Object.keys(this.apps[appName].seenToggles) : []; return this.apps[appName] ? Object.keys(this.apps[appName].seenToggles) : [];
} }
getAppsFromToggleName (toggleName) { getSeenAppsPerToggle () {
const apps = []; const toggles = {};
Object.keys(this.apps).forEach(appName => { Object.keys(this.apps).forEach(appName => {
const seenToggles = Object.keys(this.apps[appName].seenToggles); Object.keys(this.apps[appName].seenToggles).forEach((seenToggleName) => {
if (seenToggles.includes(toggleName)) { if (!toggles[seenToggleName]) {
apps.push({ toggles[seenToggleName] = [];
appName, }
}); toggles[seenToggleName].push(appName);
} });
}); });
return apps; return toggles;
} }
getTogglesMetrics () { getTogglesMetrics () {

View File

@ -20,8 +20,8 @@ module.exports = function (app, config) {
res.json(seenAppToggles); res.json(seenAppToggles);
}); });
app.get('/client/seen-apps/:name', (req, res) => { app.get('/client/seen-apps', (req, res) => {
const seenApps = metrics.getAppsFromToggleName(req.params.name); const seenApps = metrics.getSeenAppsPerToggle();
res.json(seenApps); res.json(seenApps);
}); });