From 292b9175275ba68952ec873c1e06c80d8a81f705 Mon Sep 17 00:00:00 2001 From: Sam Nicholls Date: Fri, 11 Jan 2013 22:39:32 +0000 Subject: [PATCH] Add stats to userlist [#117] --- modules/users/web.js | 15 +++++++------ modules/web/README.md | 9 ++++++++ views/layout.jade | 1 + views/users/users.jade | 50 ++++++++++++++++++++++++++++++++++++------ 4 files changed, 61 insertions(+), 14 deletions(-) diff --git a/modules/users/web.js b/modules/users/web.js index 9028553..4ea2e8a 100644 --- a/modules/users/web.js +++ b/modules/users/web.js @@ -33,26 +33,27 @@ var pages = function(dbot) { if(channelUsers[i] == dbot.config.name){ continue; } + + var user = dbot.api.stats.getUserStats(connection, channelUsers[i], channel); if(onlineNicks.hasOwnProperty(channelUsers[i])){ - var user = dbot.api.users.resolveUser(connection, channelUsers[i]); if(dbot.api.stats.isActive({'server': connection, - 'user': user, + 'user': channelUsers[i], 'channel': channel })){ - userData.active.push(channelUsers[i]); + userData.active.push(user); } else{ - userData.inactive.push(channelUsers[i]); + userData.inactive.push(user); } } else{ - userData.offline.push(channelUsers[i]); + userData.offline.push(user); } } var userSort = function(a, b){ - var x = a.toLowerCase(); - var y = b.toLowerCase(); + var x = a.display.toLowerCase(); + var y = b.display.toLowerCase(); if(x > y) return 1; if(x < y) return -1; return 0; diff --git a/modules/web/README.md b/modules/web/README.md index 1ce576b..86ebc10 100644 --- a/modules/web/README.md +++ b/modules/web/README.md @@ -14,3 +14,12 @@ wget http://twitter.github.com/bootstrap/assets/bootstrap.zip unzip bootstrap.zip rm bootstrap.zip ``` +###d3.js +``` +cd depressionbot/public/ +mkdir d3 +cd d3 +wget http://d3js.org/d3.v3.zip +unzip d3.v3.zip +rm d3.v3.zip +``` diff --git a/views/layout.jade b/views/layout.jade index f895402..cbc8ab2 100644 --- a/views/layout.jade +++ b/views/layout.jade @@ -14,5 +14,6 @@ html(lang='en') div#main block content script(type="text/javascript", src="/bootstrap/js/bootstrap.min.js") + script(type="text/javascript", src="/d3/d3.v3.min.js") script(type="text/javascript", src="/script.js") diff --git a/views/users/users.jade b/views/users/users.jade index 8770dcb..f0c345d 100644 --- a/views/users/users.jade +++ b/views/users/users.jade @@ -7,26 +7,62 @@ block content div#row table.table.table-striped thead - tr: th Users + tr + th Users + th Lines + th Words + th Lincent + th Verbosity + th Mentions tbody -each nick in nicks.active tr td - a(href='/user/'+connection+'/'+channel.substr(1,channel.length)+'/'+nick) - #{nick} + a(href='/user/'+connection+'/'+channel.substr(1,channel.length)+'/'+nick.primary) + #{nick.display} span span.label.label-success Active + td + #{nick.total_lines} + td + #{nick.total_words} + td + #{nick.lincent} + td + #{nick.wpl} + td + #{nick.in_mentions} -each nick in nicks.inactive tr td - a(href='/user/'+connection+'/'+channel.substr(1,channel.length)+'/'+nick) - #{nick} + a(href='/user/'+connection+'/'+channel.substr(1,channel.length)+'/'+nick.primary) + #{nick.display} span span.label.label-important Inactive + td + #{nick.total_lines} + td + #{nick.total_words} + td + #{nick.lincent} + td + #{nick.wpl} + td + #{nick.in_mentions} -each nick in nicks.offline tr td - a(href='/user/'+connection+'/'+channel.substr(1,channel.length)+'/'+nick) - #{nick} + a(href='/user/'+connection+'/'+channel.substr(1,channel.length)+'/'+nick.primary) + #{nick.display} span span.label Offline + td + #{nick.total_lines} + td + #{nick.total_words} + td + #{nick.lincent} + td + #{nick.wpl} + td + #{nick.in_mentions}