unify 72 magic number behind named constant

This commit is contained in:
Nick Krecklow 2020-05-08 01:27:21 -05:00
parent 7993ac0077
commit aee7b565b2
No known key found for this signature in database
GPG Key ID: 5F149FDE156FFA94
2 changed files with 6 additions and 2 deletions

@ -1,6 +1,8 @@
const config = require('../config') const config = require('../config')
const minecraftVersions = require('../minecraft_versions') const minecraftVersions = require('../minecraft_versions')
const SERVER_GRAPH_DATA_MAX_LENGTH = 72
class ServerRegistration { class ServerRegistration {
serverId serverId
lastFavicon lastFavicon
@ -105,7 +107,7 @@ class ServerRegistration {
this._pingHistory.push(ping) this._pingHistory.push(ping)
// Trim pingHistory to avoid memory leaks // Trim pingHistory to avoid memory leaks
if (this._pingHistory.length > 72) { if (this._pingHistory.length > SERVER_GRAPH_DATA_MAX_LENGTH) {
this._pingHistory.shift() this._pingHistory.shift()
} }
} }

@ -1,3 +1,5 @@
const SERVER_GRAPH_DATA_MAX_LENGTH = require('./servers').SERVER_GRAPH_DATA_MAX_LENGTH
class TimeTracker { class TimeTracker {
constructor () { constructor () {
this._points = [] this._points = []
@ -8,7 +10,7 @@ class TimeTracker {
this._points.push(timestamp) this._points.push(timestamp)
if (this._points.length > 72) { if (this._points.length > SERVER_GRAPH_DATA_MAX_LENGTH) {
this._points.shift() this._points.shift()
} }