forked from GitHub/dbot
Merge pull request #138 from SamStudio8/new_modules
Modified users web to call new stats API [Close #137]
This commit is contained in:
commit
d89fd21301
@ -1,4 +1,5 @@
|
||||
var pages = function(dbot) {
|
||||
var _ = require('underscore')._;
|
||||
var connections = dbot.instance.connections;
|
||||
|
||||
return {
|
||||
@ -26,30 +27,25 @@ 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
|
||||
})){
|
||||
userData.active.push(user);
|
||||
|
||||
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{
|
||||
userData.inactive.push(user);
|
||||
}
|
||||
}
|
||||
else{
|
||||
userData.inactive.push(user);
|
||||
userData.offline.push(user);
|
||||
}
|
||||
}
|
||||
else{
|
||||
userData.offline.push(user);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var userSort = function(a, b){
|
||||
var x = a.display.toLowerCase();
|
||||
|
@ -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}
|
||||
|
Loading…
Reference in New Issue
Block a user