From 74af9642e1c53645ecc64e28de6f2edf613e3b20 Mon Sep 17 00:00:00 2001 From: reality Date: Thu, 17 Oct 2013 11:42:05 +0000 Subject: [PATCH] make it more efficient or whatever --- modules/sstats/commands.js | 53 ++++++++------------------------------ modules/sstats/sstats.js | 42 ++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 42 deletions(-) diff --git a/modules/sstats/commands.js b/modules/sstats/commands.js index e7b661f..7d28d92 100644 --- a/modules/sstats/commands.js +++ b/modules/sstats/commands.js @@ -78,59 +78,28 @@ var commands = function(dbot) { // TODO: too much repeated code between loudest and cloudest yo '~loudest': function(event) { - var lines = {}; - this.db.scan('user_stats', function(uStats) { - lines[uStats.id] = uStats.lines; - }, function() { - var lCounts = _.chain(lines) - .pairs() - .sortBy(function(user) { return user[1]; }) - .reverse() - .first(10) - .value(); - + this.internalAPI.highscore('user_stats', 'lines', function(lCounts) { async.eachSeries(lCounts, function(lCount, next) { dbot.api.users.getUser(lCount[0], function(user) { - lCount[0] = user.primaryNick; - next(); + lCount[0] = user.primaryNick; next(); }); }, function() { - var output = "Loudest users: "; - for(var i=0;i