timersEngine.js 855 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /**
  2. *
  3. *
  4. */
  5. function MySQLBackendGaugesEngine() {
  6. var self = this;
  7. }
  8. /**
  9. *
  10. *
  11. */
  12. MySQLBackendGaugesEngine.prototype.buildQuerries = function(timers, time_stamp) {
  13. var querries = [];
  14. // Iterate on each gauge
  15. for(var timerName in timers) {
  16. var timerValue = timers[timerName];
  17. if(timerValue.length === 0) {
  18. continue;
  19. } else {
  20. for(valueIndex in timerValue){
  21. // We insert the raw timers data, you will need to calculate specific stats on the frontend
  22. querries.push("insert into `timers_statistics` values (null," + time_stamp + ",'" + timerName + "'," + timerValue[valueIndex] + ");");
  23. }
  24. }
  25. }
  26. return querries;
  27. }
  28. /**
  29. *
  30. *
  31. */
  32. exports.init = function() {
  33. var instance = new MySQLBackendGaugesEngine();
  34. return instance;
  35. };