From 103407634dd2435c8c6f8499e961b9f08d221cc9 Mon Sep 17 00:00:00 2001 From: reality Date: Sat, 24 Aug 2013 20:55:57 +0000 Subject: [PATCH] counters for channels too --- modules/report/pages.js | 14 +++++++++----- views/report/channels.jade | 6 +++--- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/modules/report/pages.js b/modules/report/pages.js index dc1a70c..7b0e308 100644 --- a/modules/report/pages.js +++ b/modules/report/pages.js @@ -12,14 +12,18 @@ var pages = function(dbot) { '/notify/:server': function(req, res) { var server = req.params.server, userCount = {}, - users = []; + users = [], + channelCount = {}; this.db.scan('notifies', function(notify) { if(!_.has(userCount, notify.user)) { - userCount[notify.user] = 1; - } else { - userCount[notify.user]++; + userCount[notify.user] = 0; } + if(!_.has(channelCount, notify.channel)) { + channelCount[notify.channel] = 0; + } + userCount[notify.user]++; + channelCount[notify.channel]++; }, function() { userCount = _.map(userCount, function(value, key) { return { @@ -40,7 +44,7 @@ var pages = function(dbot) { res.render('channels', { 'server': server, 'users': users, - 'channels': _.keys(dbot.instance.connections[server].channels) + 'channels': channelCount }); }); }); diff --git a/views/report/channels.jade b/views/report/channels.jade index 9849e3f..cd9facb 100644 --- a/views/report/channels.jade +++ b/views/report/channels.jade @@ -5,9 +5,9 @@ block content div#backlink a(href='/notify') « Server List ul#quotelist - -each channel in channels - a(href='/notify/'+server+'/'+encodeURIComponent(channel)) - li.quotes #{channel} + -each count, name in channels + a(href='/notify/'+server+'/'+encodeURIComponent(name)) + li.quotes #{name} (#{count}) h3 Browse by User on #{server} ul#quotelist