From 96acf3614b64b21c0690d09ddbfbfe85e9d6ce0c Mon Sep 17 00:00:00 2001 From: Nick Krecklow Date: Fri, 8 May 2020 03:35:22 -0500 Subject: [PATCH] explicitly set serverRegistration.playerCount when firing #addServer --- assets/js/app.js | 5 +++++ lib/ping.js | 2 ++ 2 files changed, 7 insertions(+) diff --git a/assets/js/app.js b/assets/js/app.js index 1ce52fe..d5446ce 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -115,6 +115,11 @@ export class App { // Push the historical data into the graph // This will trim and format the data so it is ready for the graph to render once init serverRegistration.addGraphPoints(payload.playerCountHistory, timestampPoints) + + // Set initial playerCount to the payload's value + // This will always exist since it is explicitly generated by the backend + // This is used for any post-add rendering of things like the percentageBar + serverRegistration.playerCount = payload.result.players.online } // Create the plot instance internally with the restructured and cleaned data diff --git a/lib/ping.js b/lib/ping.js index a9dda14..e9ae8ba 100644 --- a/lib/ping.js +++ b/lib/ping.js @@ -108,6 +108,7 @@ class PingController { // Log to database if enabled if (config.logToDatabase) { const playerCount = result.resp ? result.resp.players.online : 0 + this._app.database.insertPing(serverRegistration.data.ip, timestamp, playerCount) } @@ -115,6 +116,7 @@ class PingController { // This includes any modified fields and flags used by the frontend // This will not be cached and can contain live metadata const update = serverRegistration.handlePing(timestamp, result.resp, result.err, result.version) + updates[serverRegistration.serverId] = update }