3
0
mirror of https://github.com/reality/dbot.git synced 2024-12-24 03:33:07 +01:00

counters for channels too

This commit is contained in:
reality 2013-08-24 20:55:57 +00:00
parent 9a4111c393
commit 103407634d
2 changed files with 12 additions and 8 deletions

View File

@ -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
});
});
});

View File

@ -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