use config.graphDuration when querying database, not LIMIT
This commit is contained in:
parent
5f2c62c23a
commit
2f1c9c1dce
@ -24,7 +24,7 @@ class App {
|
||||
// Setup database instance
|
||||
this.database.ensureIndexes()
|
||||
|
||||
this.database.loadGraphPoints(this.pingController.getMaxGraphDataLength(), () => {
|
||||
this.database.loadGraphPoints(config.graphDuration, () => {
|
||||
this.database.loadRecords(callback)
|
||||
})
|
||||
}
|
||||
|
@ -14,8 +14,12 @@ class Database {
|
||||
})
|
||||
}
|
||||
|
||||
loadGraphPoints (length, callback) {
|
||||
this.getRecentPings(length, pingData => {
|
||||
loadGraphPoints (graphDuration, callback) {
|
||||
// Query recent pings
|
||||
const endTime = new Date().getTime()
|
||||
const startTime = endTime - graphDuration
|
||||
|
||||
this.getRecentPings(startTime, endTime, length, pingData => {
|
||||
const graphPointsByIp = []
|
||||
|
||||
for (const row of pingData) {
|
||||
@ -72,9 +76,10 @@ class Database {
|
||||
})
|
||||
}
|
||||
|
||||
getRecentPings (length, callback) {
|
||||
this._sql.all('SELECT * FROM pings WHERE 1 LIMIT ?', [
|
||||
length
|
||||
getRecentPings (startTime, endTime, callback) {
|
||||
this._sql.all('SELECT * FROM pings WHERE timestamp >= ? AND timestamp <= ?', [
|
||||
startTime,
|
||||
endTime
|
||||
], (_, data) => callback(data))
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user