From aee7b565b232b8788d2fbd86b050fff60f375841 Mon Sep 17 00:00:00 2001 From: Nick Krecklow Date: Fri, 8 May 2020 01:27:21 -0500 Subject: [PATCH] unify 72 magic number behind named constant --- lib/servers.js | 4 +++- lib/time.js | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/servers.js b/lib/servers.js index d0ffd90..f5c2f87 100644 --- a/lib/servers.js +++ b/lib/servers.js @@ -1,6 +1,8 @@ const config = require('../config') const minecraftVersions = require('../minecraft_versions') +const SERVER_GRAPH_DATA_MAX_LENGTH = 72 + class ServerRegistration { serverId lastFavicon @@ -105,7 +107,7 @@ class ServerRegistration { this._pingHistory.push(ping) // Trim pingHistory to avoid memory leaks - if (this._pingHistory.length > 72) { + if (this._pingHistory.length > SERVER_GRAPH_DATA_MAX_LENGTH) { this._pingHistory.shift() } } diff --git a/lib/time.js b/lib/time.js index c820ae6..a7ac7ec 100644 --- a/lib/time.js +++ b/lib/time.js @@ -1,3 +1,5 @@ +const SERVER_GRAPH_DATA_MAX_LENGTH = require('./servers').SERVER_GRAPH_DATA_MAX_LENGTH + class TimeTracker { constructor () { this._points = [] @@ -8,7 +10,7 @@ class TimeTracker { this._points.push(timestamp) - if (this._points.length > 72) { + if (this._points.length > SERVER_GRAPH_DATA_MAX_LENGTH) { this._points.shift() }