Ignore data for networks that don't exist in config.json
This commit is contained in:
parent
585b227c13
commit
a0524ce41b
@ -42,6 +42,7 @@ var bigChartOptions = {
|
|||||||
},
|
},
|
||||||
yaxis: {
|
yaxis: {
|
||||||
show: true,
|
show: true,
|
||||||
|
tickSize: 1000,
|
||||||
tickLength: 10,
|
tickLength: 10,
|
||||||
tickFormatter: function(value) {
|
tickFormatter: function(value) {
|
||||||
return formatNumber(value);
|
return formatNumber(value);
|
||||||
|
29
lib/util.js
29
lib/util.js
@ -1,10 +1,34 @@
|
|||||||
|
var config = require('../config.json');
|
||||||
|
|
||||||
|
// Checks if we have a server in config.json with the IP.
|
||||||
|
function serverWithIpExists(ip) {
|
||||||
|
for (var i = 0; i < config.servers.length; i++) {
|
||||||
|
var entry = config.servers[i];
|
||||||
|
|
||||||
|
if (entry.ip === ip) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// This method is a monstrosity.
|
// 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.
|
// 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.
|
// This is done by iterating over the list, since the time between each ping can be completely arbitrary.
|
||||||
function trimUselessPings(data) {
|
function trimUselessPings(data) {
|
||||||
var keys = Object.keys(data);
|
var keys = Object.keys(data);
|
||||||
|
|
||||||
|
var keysToRemove = [];
|
||||||
|
|
||||||
for (var i = 0; i < keys.length; i++) {
|
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 listing = data[keys[i]];
|
||||||
var lastTimestamp = 0;
|
var lastTimestamp = 0;
|
||||||
|
|
||||||
@ -30,6 +54,11 @@ function trimUselessPings(data) {
|
|||||||
|
|
||||||
data[keys[i]] = filteredListing;
|
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[entry];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.getCurrentTimeMs = function() {
|
exports.getCurrentTimeMs = function() {
|
||||||
|
Loading…
Reference in New Issue
Block a user