Skip to content

Commit 8164d51

Browse files
authored
Update server-stats scripts
1 parent 32b7175 commit 8164d51

File tree

1 file changed

+8
-10
lines changed
  • plugins/server-stats/scripts

1 file changed

+8
-10
lines changed

plugins/server-stats/scripts/top.js

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,23 @@ if (myArgs[0] === "help") {
88
}
99
pluginManager.dbConnection().then((db) => {
1010
stats.getTop(db, {}, function(toReturn) {
11-
var apps = Object.keys(toReturn);
11+
var apps = toReturn.map(o => o.a);
1212
db.collection("apps").find({_id: {$in: apps.map(id => db.ObjectID(id))}}, {projection: {name: 1}}).toArray(function(err, appResult) {
1313
if (appResult) {
1414
for (let i = 0; i < appResult.length; i++) {
1515
appNames[appResult[i]._id] = appResult[i].name;
1616
}
1717
}
1818
db.close();
19-
var res = [];
20-
for (let app in toReturn) {
21-
if (toReturn[app]) {
22-
toReturn[app].app = stats.getAppName(app, appNames);
23-
res.push(toReturn[app]);
19+
for (let i = 0; i < toReturn.length; i++) {
20+
if (toReturn[i].a) {
21+
toReturn[i].a = stats.getAppName(toReturn[i].a, appNames);
2422
}
2523
}
26-
res.sort(function(a, b) {
27-
return b["data-points"] - a["data-points"];
24+
toReturn.sort(function(a, b) {
25+
return b["v"] - a["v"];
2826
});
29-
console.table(res, ["app", "data-points"]);
27+
console.table(toReturn, ["a", "v"]);
3028
});
3129
});
32-
});
30+
});

0 commit comments

Comments
 (0)