Fixed server stats for SQL databases.
Ylian Saint-Hilaire committed
Nov 8, 2021 at 10:31 UTC
72b92284d45adf87827debfdcfa51c5d325d6c17
1 file changed
+2
-2
db.js
+2
-2
@@ -1253,7 +1253,7 @@ module.exports.CreateDB = function (parent, func) {
1253
1254
// Database actions on the Server Stats collection
1255
obj.SetServerStats = function (data, func) { sqlDbQuery('INSERT INTO serverstats VALUES ($1, $2, $3) ON CONFLICT (time) DO UPDATE SET expire = $2, doc = $3', [data.time, data.expire, data], func); };
1256
- obj.GetServerStats = function (hours, func) { var t = new Date(); t.setTime(t.getTime() - (60 * 60 * 1000 * hours)); sqlDbQuery('SELECT doc FROM serverstats WHERE time < $1', [t], func); }; // TODO: Expire old entries
1256
+ obj.GetServerStats = function (hours, func) { var t = new Date(); t.setTime(t.getTime() - (60 * 60 * 1000 * hours)); sqlDbQuery('SELECT doc FROM serverstats WHERE time > $1', [t], func); }; // TODO: Expire old entries
1257
1258
// Read a configuration file from the database
1259
obj.getConfigFile = function (path, func) { obj.Get('cfile/' + path, func); }
@@ -1422,7 +1422,7 @@ module.exports.CreateDB = function (parent, func) {
1422
1423
// Database actions on the Server Stats collection
1424
obj.SetServerStats = function (data, func) { sqlDbQuery('REPLACE INTO serverstats VALUE (?, ?, ?)', [data.time, data.expire, JSON.stringify(data)], func); };
1425
- obj.GetServerStats = function (hours, func) { var t = new Date(); t.setTime(t.getTime() - (60 * 60 * 1000 * hours)); sqlDbQuery('SELECT doc FROM serverstats WHERE time < ?', [t], func); }; // TODO: Expire old entries
1425
+ obj.GetServerStats = function (hours, func) { var t = new Date(); t.setTime(t.getTime() - (60 * 60 * 1000 * hours)); sqlDbQuery('SELECT doc FROM serverstats WHERE time > ?', [t], func); }; // TODO: Expire old entries
1426
1427
// Read a configuration file from the database
1428
obj.getConfigFile = function (path, func) { obj.Get('cfile/' + path, func); }