From 0402df0bc6527cb2e73a35855f8edb40f24c0532 Mon Sep 17 00:00:00 2001 From: Nick Krecklow Date: Wed, 22 Apr 2020 17:30:47 -0500 Subject: [PATCH] test fix for historical graph retaining too much data --- lib/servers.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) 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 }