diff --git a/README.md b/README.md index 4f5b95c..3ad54fd 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,12 @@ git clone https://github.com/fradinni/nodejs-statsd-mysql-backend.git ``` You should have a new directory called 'nodejs-statsd-mysql-backend' just next to the Statsd directory. +It could be required to execute the next commands: +``` +npm install mysql +npm install sequence +``` + ## Configuration Edit Statsd configuraton file and add mysql-backend configuration. diff --git a/engines/countersEngine.js b/engines/countersEngine.js index 7a0363e..d3d2331 100644 --- a/engines/countersEngine.js +++ b/engines/countersEngine.js @@ -27,7 +27,13 @@ MySQLBackendCountersEngine.prototype.buildQuerries = function(userCounters, time * - userCounterName: Counter name * - counterValue: Counter value */ - querries.push("insert into `counters_statistics` select "+time_stamp+", '"+userCounterName+"' , if(max(value),max(value),0) + "+counterValue+" from `counters_statistics` where if(name = '"+userCounterName+"', 1,0) = 1 ;"); + + // old strategy + // querries.push("insert into `counters_statistics` select "+time_stamp+", '"+userCounterName+"' , if(max(value),max(value),0) + "+counterValue+" from `counters_statistics` where if(name = '"+userCounterName+"', 1,0) = 1 ;"); + + // new strategy + querries.push("INSERT INTO `counters_statistics` (`timestamp`, `name`, `value`) VALUES ("+time_stamp+", '"+userCounterName+"', "+counterValue+")"); + } } @@ -43,4 +49,4 @@ MySQLBackendCountersEngine.prototype.buildQuerries = function(userCounters, time exports.init = function() { var instance = new MySQLBackendCountersEngine(); return instance; -}; \ No newline at end of file +};