diff --git a/lib/servers.js b/lib/servers.js index 0ad6dd6..919be31 100644 --- a/lib/servers.js +++ b/lib/servers.js @@ -171,13 +171,8 @@ class ServerRegistration { this._lastGraphDataPush = timestamp // Trim old graphPoints according to graphDuration - for (let i = 1; i < this.graphData.length; i++) { - // Find a break point where i - 1 is too old and i is new - if (timestamp - this.graphData[i - 1][0] > config.graphDuration && timestamp - this.graphData[i] <= config.graphDuration) { - this.graphData.splice(0, i) - break - } - } + const filterTimestamp = new Date().getTime() - config.graphDuration + this.graphData = this.graphData.filter(point => point[0] >= filterTimestamp) return true }