2020-05-08 06:27:21 +00:00
|
|
|
const SERVER_GRAPH_DATA_MAX_LENGTH = require('./servers').SERVER_GRAPH_DATA_MAX_LENGTH
|
|
|
|
|
2020-05-08 06:22:07 +00:00
|
|
|
class TimeTracker {
|
|
|
|
constructor () {
|
|
|
|
this._points = []
|
|
|
|
}
|
|
|
|
|
|
|
|
newTimestamp () {
|
|
|
|
const timestamp = new Date().getTime()
|
|
|
|
|
|
|
|
this._points.push(timestamp)
|
|
|
|
|
2020-05-08 06:27:21 +00:00
|
|
|
if (this._points.length > SERVER_GRAPH_DATA_MAX_LENGTH) {
|
2020-05-08 06:22:07 +00:00
|
|
|
this._points.shift()
|
|
|
|
}
|
|
|
|
|
|
|
|
return timestamp
|
|
|
|
}
|
|
|
|
|
|
|
|
getPoints () {
|
|
|
|
return this._points
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = TimeTracker
|