prevent undefined/null values breaking graphs or scales

This commit is contained in:
Nick Krecklow
2020-06-12 18:59:59 -05:00
parent 5b6d65e1c9
commit 7313971871
3 changed files with 12 additions and 7 deletions

View File

@ -45,6 +45,10 @@ class ServerRegistration {
getUpdate (timestamp, resp, err, version) {
const update = {}
// Always append a playerCount value
// When resp is undefined (due to an error), playerCount will be null
update.playerCount = getPlayerCountOrNull(resp)
if (resp) {
if (resp.version && this.updateProtocolVersionCompat(resp.version, version.protocolId, version.protocolIndex)) {
// Append an updated version listing
@ -65,10 +69,6 @@ class ServerRegistration {
update.favicon = this.getFaviconUrl()
}
// Append a result object
// This filters out unwanted data from resp
update.playerCount = resp.players.online
if (config.logToDatabase) {
// Update calculated graph peak regardless if the graph is being updated
// This can cause a (harmless) desync between live and stored data, but it allows it to be more accurate for long surviving processes