merge graph timestamps into single array, use seconds

This commit is contained in:
Nick Krecklow
2020-05-11 04:12:46 -05:00
parent ef0c41ee1d
commit 84004f22be
9 changed files with 64 additions and 100 deletions

View File

@ -41,18 +41,19 @@ class App {
if (config.logToDatabase) {
client.on('message', (message) => {
if (message === 'requestHistoryGraph') {
// Send historical graphData built from all serverRegistrations
const graphData = {}
// FIXME: update schema, remove timestamp
// Since all history graph updates share timestamps, pull the timestamps from a single ServerRegistration
const timestamps = this.serverRegistrations[0].graphData.map(point => Math.floor(point[0] / 1000))
this.serverRegistrations.forEach((serverRegistration) => {
graphData[serverRegistration.serverId] = serverRegistration.graphData
})
// Send historical graphData built from all serverRegistrations
const graphData = this.serverRegistrations.map(serverRegistration => serverRegistration.graphData.map(point => point[1]))
// Send graphData in object wrapper to avoid needing to explicity filter
// any header data being appended by #MessageOf since the graph data is fed
// directly into the graphing system
client.send(MessageOf('historyGraph', {
graphData: graphData
timestamps,
graphData
}))
}
})
@ -77,7 +78,7 @@ class App {
}
})(),
mojangServices: this.mojangUpdater.getLastUpdate(),
timestampPoints: this.timeTracker.getPoints(),
timestampPoints: this.timeTracker.getPointsSeconds(),
servers: this.serverRegistrations.map(serverRegistration => serverRegistration.getPingHistory())
}