Fix legacy code problems
This commit is contained in:
parent
266eff4668
commit
f6a27f0469
33
lib/util.js
33
lib/util.js
@ -5,19 +5,6 @@ var servers = require('../servers.json');
|
||||
|
||||
var serverNameLookup = {};
|
||||
|
||||
// Checks if we have a server in config.json with the IP.
|
||||
function serverWithIpExists(ip) {
|
||||
for (var i = 0; i < servers.length; i++) {
|
||||
var entry = servers[i];
|
||||
|
||||
if (entry.ip === ip) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function getServerNameByIp(ip) {
|
||||
var lookupName = serverNameLookup[ip];
|
||||
|
||||
@ -52,16 +39,7 @@ function getServerIps() {
|
||||
function trimUselessPings(data) {
|
||||
var keys = Object.keys(data);
|
||||
|
||||
var keysToRemove = [];
|
||||
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
// Don't bother we servers we deleted from config.json
|
||||
if (!serverWithIpExists(keys[i])) {
|
||||
keysToRemove.push(keys[i]);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
var listing = data[keys[i]];
|
||||
var lastTimestamp = 0;
|
||||
|
||||
@ -87,11 +65,6 @@ function trimUselessPings(data) {
|
||||
|
||||
data[keys[i]] = filteredListing;
|
||||
}
|
||||
|
||||
// Delete data for any networks we don't care about anymore.
|
||||
for (var i = 0; i < keysToRemove.length; i++) {
|
||||
delete data[keysToRemove[i]];
|
||||
}
|
||||
}
|
||||
|
||||
exports.trimOldPings = function(data) {
|
||||
@ -142,12 +115,6 @@ exports.convertPingsToGraph = function(sqlData) {
|
||||
|
||||
var name = getServerNameByIp(entry.ip);
|
||||
|
||||
if (!name) {
|
||||
logger.warn('Missing name for ' + entry.ip);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!graphData[name]) {
|
||||
graphData[name] = [];
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user