From 54f4d4979ca4a86db8d8ec3a380731f1a9e63de6 Mon Sep 17 00:00:00 2001 From: reality Date: Fri, 2 Jan 2015 21:38:37 +0000 Subject: [PATCH] types --- modules/report/commands.js | 29 ++++++++++++++++++++++------- modules/report/strings.json | 4 ++-- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/modules/report/commands.js b/modules/report/commands.js index be5469e..a89f1b2 100644 --- a/modules/report/commands.js +++ b/modules/report/commands.js @@ -5,12 +5,11 @@ var commands = function(dbot) { var commands = { '~ncount': function(event) { var chanCounts = {}, + typeCounts = {}, total = 0, offString = event.params[1] || null; offset = moment().subtract(offString, 1).valueOf() || null; - console.log(offset); - /*if(!offset || !offset.isValid()) { event.reply('Invalid timescale. Try \'week\''); return; @@ -20,15 +19,16 @@ var commands = function(dbot) { if(notify.user == event.rUser.id) { if(!offString) { if(!_.has(chanCounts, notify.channel)) chanCounts[notify.channel] = 0; + if(!_.has(typeCounts, notify.type)) typeCounts[notify.type] = 0; chanCounts[notify.channel]++; + typeCounts[notify.type]++; total++; } else { - console.log(offset); - console.log(notify.time); - console.log(); if(notify.time > offset) { if(!_.has(chanCounts, notify.channel)) chanCounts[notify.channel] = 0; + if(!_.has(typeCounts, notify.type)) typeCounts[notify.type] = 0; chanCounts[notify.channel]++; + typeCounts[notify.type]++; total++; } } @@ -47,18 +47,33 @@ var commands = function(dbot) { } cString = cString.slice(0, -2); + var tCounts = _.chain(typeCounts) + .pairs() + .sortBy(function(p) { return p[1]; }) + .reverse() + .first(10) + .value(); + + var cttring = ''; + for(var i=0;i