centralize timestamp/point filtering, move magic numbers into named constants
This commit is contained in:
@ -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 () {
|
||||
|
Reference in New Issue
Block a user