فهرست منبع

Merge pull request #11 from PavelPolyakov/master

The backend works only after the stated changes
Nicolas FRADIN 10 سال پیش
والد
کامیت
4d1febbbd3
2فایلهای تغییر یافته به همراه14 افزوده شده و 2 حذف شده
  1. 6 0
      README.md
  2. 8 2
      engines/countersEngine.js

+ 6 - 0
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.
 

+ 8 - 2
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;
-};
+};