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,20 +27,14 @@ 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 onlineNicks = connections[connection].channels[channel].nicks; var reply = dbot.api.stats.getChanUsersStats(connection, channel, [
for(var i=0;i<channelUsers.length;i++) { "lines", "words", "lincent", "wpl", "in_mentions"
if(channelUsers[i] == dbot.config.name){ ]);
continue; _.each(reply.users, function(user, userName){
} if(userName != dbot.config.name){
if(user.online){
var user = dbot.api.stats.getUserStats(connection, channelUsers[i], channel); if(user.active){
if(onlineNicks.hasOwnProperty(channelUsers[i])){
if(dbot.api.stats.isActive({'server': connection,
'user': channelUsers[i],
'channel': channel
})){
userData.active.push(user); userData.active.push(user);
} }
else{ else{
@ -50,6 +45,7 @@ var pages = function(dbot) {
userData.offline.push(user); 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}