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:
parent
e9938d9a5b
commit
421a6413bf
@ -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 () {
|
||||
|
@ -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);
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user