explicitly set serverRegistration.playerCount when firing #addServer

This commit is contained in:
Nick Krecklow 2020-05-08 03:35:22 -05:00
parent 4104c4144a
commit 96acf3614b
No known key found for this signature in database
GPG Key ID: 5F149FDE156FFA94
2 changed files with 7 additions and 0 deletions

@ -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

@ -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
}