Merge pull request #237 from SamStudio8/master

Testing rolling week [#216]
This commit is contained in:
Luke Slater 2013-01-27 15:39:19 -08:00
commit 760c57cb8c
2 changed files with 14 additions and 4 deletions

View File

@ -26,18 +26,24 @@ var pages = function(dbot) {
if(connections.hasOwnProperty(connection) && if(connections.hasOwnProperty(connection) &&
connections[connection].channels.hasOwnProperty(channel)) { connections[connection].channels.hasOwnProperty(channel)) {
var chanData = dbot.api.stats.getChanStats(connection, channel, ["freq"]); //TODO(samstudio8): Stats API Functionality
var chanData = dbot.api.stats.getChanStats(connection, channel, ["week"]);
var chanFreq = []; var chanFreq = [];
var chanFreqLabel = [];
if(chanData){ if(chanData){
var cur_ptr;
for(var i=0; i <= 6; i++){ for(var i=0; i <= 6; i++){
cur_ptr = ((i+1)+chanData.fields.week.raw.ptr) % 7;
for(var j=0; j <= 23; j++){ for(var j=0; j <= 23; j++){
chanFreq.push(chanData.fields.freq.raw[i][j]); chanFreq.push(chanData.fields.week.raw[cur_ptr][j]);
} }
chanFreqLabel.push("'"+chanData.fields.week.raw[cur_ptr].name+"'");
} }
} }
else{ else{
for (var i = 0; i < 168; i++) chanFreq[i] = 0; for (var i = 0; i < 168; i++) chanFreq[i] = 0;
chanFreqLabel = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"];
} }
var userData = { "active": [], "inactive": [], "offline": []}; var userData = { "active": [], "inactive": [], "offline": []};
@ -79,7 +85,10 @@ var pages = function(dbot) {
'channel': channel, 'channel': channel,
'userStats': userDataSorted, 'userStats': userDataSorted,
'chanFreq': chanFreq, 'chanFreq': chanFreq,
'chanFreqLen': chanFreq.length }); 'chanFreqLen': chanFreq.length,
"locals": {
'chanFreqLabel': chanFreqLabel,
}});
} else { } else {
res.render_core('error', { 'name': dbot.config.name, 'message': 'No such connection or channel.' }); res.render_core('error', { 'name': dbot.config.name, 'message': 'No such connection or channel.' });

View File

@ -94,7 +94,7 @@ block content
.text(String); .text(String);
chart.selectAll("text.days") chart.selectAll("text.days")
.data(["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]) .data([!{locals.chanFreqLabel}])
.enter().append("text") .enter().append("text")
.attr("x", function(d, i){ return ((i+0.5) * w * 24) + ticks; }) .attr("x", function(d, i){ return ((i+0.5) * w * 24) + ticks; })
.attr("y", h + 25) .attr("y", h + 25)
@ -149,6 +149,7 @@ block content
div#backlink div#backlink
a(href='/channels/'+connection) &laquo; Channel List a(href='/channels/'+connection) &laquo; Channel List
div#row div#row
h4 Seven Day Activity
div.barchart#chanFreqChart div.barchart#chanFreqChart
hr hr
div#row div#row