centralize timestamp/point filtering, move magic numbers into named constants

This commit is contained in:
Nick Krecklow
2020-05-11 18:44:29 -05:00
parent 3998b688ab
commit 0c98930d4c
5 changed files with 30 additions and 30 deletions

View File

@ -1,7 +1,7 @@
const crypto = require('crypto')
const dns = require('dns')
const TimeTracker = require('./time')
const { GRAPH_UPDATE_TIME_GAP, TimeTracker } = require('./time')
const Server = require('./server')
const { getPlayerCountOrNull } = require('./util')
@ -124,18 +124,7 @@ class ServerRegistration {
}
loadGraphPoints (startTime, timestamps, points) {
// Filter pings so each result is a minute apart
let lastTimestamp = startTime
for (let i = 0; i < timestamps.length; i++) {
const timestamp = timestamps[i]
if (timestamp - lastTimestamp >= 60 * 1000) {
lastTimestamp = timestamp
this.graphData.push(points[i])
}
}
this.graphData = TimeTracker.everyN(timestamps, startTime, GRAPH_UPDATE_TIME_GAP, (i) => points[i])
}
findNewGraphPeak () {