share a single timestamp array between all graphData objects

This commit is contained in:
Nick Krecklow
2020-05-11 18:12:29 -05:00
parent 59ec7d151f
commit c2f6d04e72
10 changed files with 100 additions and 52 deletions

View File

@ -41,18 +41,14 @@ class App {
if (config.logToDatabase) {
client.on('message', (message) => {
if (message === 'requestHistoryGraph') {
// 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))
// Send historical graphData built from all serverRegistrations
const graphData = this.serverRegistrations.map(serverRegistration => serverRegistration.graphData.map(point => point[1]))
const graphData = this.serverRegistrations.map(serverRegistration => serverRegistration.graphData)
// 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', {
timestamps,
timestamps: this.timeTracker.getHistoricalPointsSeconds(),
graphData
}))
}
@ -78,7 +74,7 @@ class App {
}
})(),
mojangServices: this.mojangUpdater.getLastUpdate(),
timestampPoints: this.timeTracker.getPointsSeconds(),
timestampPoints: this.timeTracker.getServerPointsSeconds(),
servers: this.serverRegistrations.map(serverRegistration => serverRegistration.getPingHistory())
}