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

View File

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