forked from GitHub/dbot
counters for channels too
This commit is contained in:
parent
9a4111c393
commit
103407634d
@ -12,14 +12,18 @@ var pages = function(dbot) {
|
|||||||
'/notify/:server': function(req, res) {
|
'/notify/:server': function(req, res) {
|
||||||
var server = req.params.server,
|
var server = req.params.server,
|
||||||
userCount = {},
|
userCount = {},
|
||||||
users = [];
|
users = [],
|
||||||
|
channelCount = {};
|
||||||
|
|
||||||
this.db.scan('notifies', function(notify) {
|
this.db.scan('notifies', function(notify) {
|
||||||
if(!_.has(userCount, notify.user)) {
|
if(!_.has(userCount, notify.user)) {
|
||||||
userCount[notify.user] = 1;
|
userCount[notify.user] = 0;
|
||||||
} else {
|
|
||||||
userCount[notify.user]++;
|
|
||||||
}
|
}
|
||||||
|
if(!_.has(channelCount, notify.channel)) {
|
||||||
|
channelCount[notify.channel] = 0;
|
||||||
|
}
|
||||||
|
userCount[notify.user]++;
|
||||||
|
channelCount[notify.channel]++;
|
||||||
}, function() {
|
}, function() {
|
||||||
userCount = _.map(userCount, function(value, key) {
|
userCount = _.map(userCount, function(value, key) {
|
||||||
return {
|
return {
|
||||||
@ -40,7 +44,7 @@ var pages = function(dbot) {
|
|||||||
res.render('channels', {
|
res.render('channels', {
|
||||||
'server': server,
|
'server': server,
|
||||||
'users': users,
|
'users': users,
|
||||||
'channels': _.keys(dbot.instance.connections[server].channels)
|
'channels': channelCount
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -5,9 +5,9 @@ block content
|
|||||||
div#backlink
|
div#backlink
|
||||||
a(href='/notify') « Server List
|
a(href='/notify') « Server List
|
||||||
ul#quotelist
|
ul#quotelist
|
||||||
-each channel in channels
|
-each count, name in channels
|
||||||
a(href='/notify/'+server+'/'+encodeURIComponent(channel))
|
a(href='/notify/'+server+'/'+encodeURIComponent(name))
|
||||||
li.quotes #{channel}
|
li.quotes #{name} (#{count})
|
||||||
|
|
||||||
h3 Browse by User on #{server}
|
h3 Browse by User on #{server}
|
||||||
ul#quotelist
|
ul#quotelist
|
||||||
|
Loading…
Reference in New Issue
Block a user