Graph smoothing
This commit is contained in:
parent
7e4d3c1f58
commit
d07a315208
5
app.js
5
app.js
@ -86,7 +86,10 @@ function pingAll() {
|
||||
// Push it to our graphs.
|
||||
var timeMs = util.getCurrentTimeMs();
|
||||
|
||||
if (!lastGraphPush[network.ip] || timeMs - lastGraphPush[network.ip] >= 60 * 1000) {
|
||||
// The same mechanic from trimUselessPings is seen here.
|
||||
// If we dropped the ping, then to avoid destroying the graph, ignore it.
|
||||
// However if it's been too long since the last successful ping, we'll send it anyways.
|
||||
if (!lastGraphPush[network.ip] || (timeMs - lastGraphPush[network.ip] >= 60 * 1000 && res) || timeMs - lastGraphPush[network.ip] >= 70 * 1000) {
|
||||
lastGraphPush[network.ip] = timeMs;
|
||||
|
||||
// Don't have too much data!
|
||||
|
@ -110,11 +110,6 @@
|
||||
"ip": "play.gotpvp.com",
|
||||
"type": "PC"
|
||||
},
|
||||
{
|
||||
"name": "MCLegends",
|
||||
"ip": "play.mc-legends.com",
|
||||
"type": "PC"
|
||||
},
|
||||
{
|
||||
"name": "Rewinside",
|
||||
"ip": "mc.rewinside.tv",
|
||||
|
@ -16,11 +16,17 @@ function trimUselessPings(data) {
|
||||
// 0 is the index of the timestamp.
|
||||
// See the convertPingsToGraph method.
|
||||
if (entry[0] - lastTimestamp >= 60 * 1000) {
|
||||
// This second check tries to smooth out randomly dropped pings.
|
||||
// By default we only want entries that are online (playerCount > 0).
|
||||
// This way we'll keep looking forward until we find one that is online.
|
||||
// However if we can't find one within a reasonable timeframe, select the sucky one.
|
||||
if (entry[0] - lastTimestamp >= 120 * 1000 || entry[1] > 0) {
|
||||
filteredListing.push(entry);
|
||||
|
||||
lastTimestamp = entry[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
data[keys[i]] = filteredListing;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user