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
|
// Setup database instance
|
||||||
this.database.ensureIndexes()
|
this.database.ensureIndexes()
|
||||||
|
|
||||||
this.database.loadGraphPoints(this.pingController.getMaxGraphDataLength(), () => {
|
this.database.loadGraphPoints(config.graphDuration, () => {
|
||||||
this.database.loadRecords(callback)
|
this.database.loadRecords(callback)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -14,8 +14,12 @@ class Database {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
loadGraphPoints (length, callback) {
|
loadGraphPoints (graphDuration, callback) {
|
||||||
this.getRecentPings(length, pingData => {
|
// Query recent pings
|
||||||
|
const endTime = new Date().getTime()
|
||||||
|
const startTime = endTime - graphDuration
|
||||||
|
|
||||||
|
this.getRecentPings(startTime, endTime, length, pingData => {
|
||||||
const graphPointsByIp = []
|
const graphPointsByIp = []
|
||||||
|
|
||||||
for (const row of pingData) {
|
for (const row of pingData) {
|
||||||
@ -72,9 +76,10 @@ class Database {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
getRecentPings (length, callback) {
|
getRecentPings (startTime, endTime, callback) {
|
||||||
this._sql.all('SELECT * FROM pings WHERE 1 LIMIT ?', [
|
this._sql.all('SELECT * FROM pings WHERE timestamp >= ? AND timestamp <= ?', [
|
||||||
length
|
startTime,
|
||||||
|
endTime
|
||||||
], (_, data) => callback(data))
|
], (_, data) => callback(data))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user