Browse Source

counters should flush

Pavel Polyakov 11 năm trước cách đây
mục cha
commit
e110dcda06
1 tập tin đã thay đổi với 8 bổ sung2 xóa
  1. 8 2
      engines/countersEngine.js

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