3
0
mirror of https://github.com/reality/dbot.git synced 2024-11-23 20:39:25 +01:00

Modified users web to call new stats API [Close #137]

This commit is contained in:
Sam Nicholls 2013-01-15 15:10:28 +00:00
parent 0a3d1b6f9e
commit 44764cd2b3
2 changed files with 31 additions and 35 deletions

View File

@ -1,4 +1,5 @@
var pages = function(dbot) { var pages = function(dbot) {
var _ = require('underscore')._;
var connections = dbot.instance.connections; var connections = dbot.instance.connections;
return { return {
@ -26,30 +27,25 @@ var pages = function(dbot) {
connections[connection].channels.hasOwnProperty(channel)) { connections[connection].channels.hasOwnProperty(channel)) {
var userData = { "active": [], "inactive": [], "offline": []}; var userData = { "active": [], "inactive": [], "offline": []};
var channelUsers = dbot.db.knownUsers[connection].channelUsers[channel];
var reply = dbot.api.stats.getChanUsersStats(connection, channel, [
var onlineNicks = connections[connection].channels[channel].nicks; "lines", "words", "lincent", "wpl", "in_mentions"
for(var i=0;i<channelUsers.length;i++) { ]);
if(channelUsers[i] == dbot.config.name){ _.each(reply.users, function(user, userName){
continue; if(userName != dbot.config.name){
} if(user.online){
if(user.active){
var user = dbot.api.stats.getUserStats(connection, channelUsers[i], channel); userData.active.push(user);
if(onlineNicks.hasOwnProperty(channelUsers[i])){ }
if(dbot.api.stats.isActive({'server': connection, else{
'user': channelUsers[i], userData.inactive.push(user);
'channel': channel }
})){
userData.active.push(user);
} }
else{ else{
userData.inactive.push(user); userData.offline.push(user);
} }
} }
else{ });
userData.offline.push(user);
}
}
var userSort = function(a, b){ var userSort = function(a, b){
var x = a.display.toLowerCase(); var x = a.display.toLowerCase();

View File

@ -23,15 +23,15 @@ block content
span span
span.label.label-success Active span.label.label-success Active
td td
#{nick.total_lines} #{nick.fields.lines.data}
td td
#{nick.total_words} #{nick.fields.words.data}
td td
#{nick.lincent} #{nick.fields.lincent.data}
td td
#{nick.wpl} #{nick.fields.wpl.data}
td td
#{nick.in_mentions} #{nick.fields.in_mentions.data}
-each nick in nicks.inactive -each nick in nicks.inactive
tr tr
td td
@ -40,15 +40,15 @@ block content
span span
span.label.label-important Inactive span.label.label-important Inactive
td td
#{nick.total_lines} #{nick.fields.lines.data}
td td
#{nick.total_words} #{nick.fields.words.data}
td td
#{nick.lincent} #{nick.fields.lincent.data}
td td
#{nick.wpl} #{nick.fields.wpl.data}
td td
#{nick.in_mentions} #{nick.fields.in_mentions.data}
-each nick in nicks.offline -each nick in nicks.offline
tr tr
td td
@ -57,12 +57,12 @@ block content
span span
span.label Offline span.label Offline
td td
#{nick.total_lines} #{nick.fields.lines.data}
td td
#{nick.total_words} #{nick.fields.words.data}
td td
#{nick.lincent} #{nick.fields.lincent.data}
td td
#{nick.wpl} #{nick.fields.wpl.data}
td td
#{nick.in_mentions} #{nick.fields.in_mentions.data}