1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-28 00:06:53 +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) : [];
}
getAppsFromToggleName (toggleName) {
const apps = [];
getSeenAppsPerToggle () {
const toggles = {};
Object.keys(this.apps).forEach(appName => {
const seenToggles = Object.keys(this.apps[appName].seenToggles);
if (seenToggles.includes(toggleName)) {
apps.push({
appName,
});
}
Object.keys(this.apps[appName].seenToggles).forEach((seenToggleName) => {
if (!toggles[seenToggleName]) {
toggles[seenToggleName] = [];
}
toggles[seenToggleName].push(appName);
});
});
return apps;
return toggles;
}
getTogglesMetrics () {

View File

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