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: {
|
||||
show: true,
|
||||
tickSize: 1000,
|
||||
tickLength: 10,
|
||||
tickFormatter: function(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.
|
||||
// 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.
|
||||
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;
|
||||
|
||||
@ -30,6 +54,11 @@ 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[entry];
|
||||
}
|
||||
}
|
||||
|
||||
exports.getCurrentTimeMs = function() {
|
||||
|
Loading…
Reference in New Issue
Block a user