From 3dc10f571fe29da0c6b1940886846e6a837fc913 Mon Sep 17 00:00:00 2001 From: Cryptkeeper Date: Mon, 1 Feb 2016 04:55:37 -0600 Subject: [PATCH] Correctly ignore old servers in the db --- lib/util.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/util.js b/lib/util.js index 39c4039..1801726 100644 --- a/lib/util.js +++ b/lib/util.js @@ -36,6 +36,16 @@ function getServerNameByIp(ip) { } } +function getServerIps() { + var ips = []; + + for (var i = 0; i < servers.length; i++) { + ips.push(servers[i].ip); + } + + return ips; +} + // This method is a monstrosity. // Since we loaded ALL pings from the database, we need to filter out the pings so each entry is a minute apart. // This is done by iterating over the list, since the time between each ping can be completely arbitrary. @@ -120,11 +130,16 @@ exports.setIntervalNoDelay = function(func, delay) { }; exports.convertPingsToGraph = function(sqlData) { + var serverIps = getServerIps(); var graphData = {}; for (var i = 0; i < sqlData.length; i++) { var entry = sqlData[i]; + if (serverIps.indexOf(entry.ip) === -1) { + continue; + } + var name = getServerNameByIp(entry.ip); if (!name) {