Fixlet to configuration tunable value check.
[e-mobility-charging-stations-simulator.git] / src / utils / Statistics.js
index bba3d6b174fd829b8dcc9e714042ae67363c2e1d..5289a5749326c976500bb19987652d691cf2056b 100644 (file)
@@ -40,7 +40,8 @@ class Statistics {
       startTransaction: 'StartTransaction',
       stopTransaction: 'StopTransaction',
     };
-    if (MAPCOMMAND[command]) { // Get current command statistics
+    // Get current command statistics
+    if (MAPCOMMAND[command]) {
       currentStatistics = this._statistics[MAPCOMMAND[command]];
     } else if (this._statistics[command]) {
       currentStatistics = this._statistics[command];
@@ -51,10 +52,10 @@ class Statistics {
 
     if (currentStatistics) {
       // Update current statistics timers
-      currentStatistics.countTime = (currentStatistics.countTime ? currentStatistics.countTime + 1 : 1);
-      currentStatistics.minTime = (currentStatistics.minTime ? (currentStatistics.minTime > duration ? duration : currentStatistics.minTime) : duration);
-      currentStatistics.maxTime = (currentStatistics.maxTime ? (currentStatistics.maxTime < duration ? duration : currentStatistics.maxTime) : duration);
-      currentStatistics.totalTime = (currentStatistics.totalTime ? currentStatistics.totalTime + duration : duration);
+      currentStatistics.countTime = currentStatistics.countTime ? currentStatistics.countTime + 1 : 1;
+      currentStatistics.minTime = currentStatistics.minTime ? (currentStatistics.minTime > duration ? duration : currentStatistics.minTime) : duration;
+      currentStatistics.maxTime = currentStatistics.maxTime ? (currentStatistics.maxTime < duration ? duration : currentStatistics.maxTime) : duration;
+      currentStatistics.totalTime = currentStatistics.totalTime ? currentStatistics.totalTime + duration : duration;
       currentStatistics.avgTime = currentStatistics.totalTime / currentStatistics.countTime;
     }
   }
@@ -65,17 +66,15 @@ class Statistics {
   }
 
   _display() {
-    // logger.info(this._basicFormatLog() + ' STARTING')
     logger.info(this._basicFormatLog() + ' %j', this._statistics);
-    // logger.info(this._basicFormatLog() + ' ENDING')
   }
 
   _displayInterval() {
-    if (Configuration.getStatisticsDisplayInterval()) {
-      logger.info(this._basicFormatLog() + ' displayed every ' + Configuration.getStatisticsDisplayInterval() + 's');
+    if (Configuration.getStatisticsDisplayInterval() > 0) {
       setInterval(() => {
         this._display();
       }, Configuration.getStatisticsDisplayInterval() * 1000);
+      logger.info(this._basicFormatLog() + ' displayed every ' + Configuration.getStatisticsDisplayInterval() + 's');
     }
   }