From 53249de7990f5a8856b53014da4ea768bada9eb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Wed, 9 Mar 2016 22:15:03 +0200 Subject: [PATCH] fix performance issue with acp --- src/controllers/admin/dashboard.js | 6 +++--- src/controllers/admin/users.js | 2 +- src/controllers/users.js | 2 +- src/user.js | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/controllers/admin/dashboard.js b/src/controllers/admin/dashboard.js index 565d23e563..24a65983f1 100644 --- a/src/controllers/admin/dashboard.js +++ b/src/controllers/admin/dashboard.js @@ -81,13 +81,13 @@ function getStatsForSet(set, field, callback) { var now = Date.now(); async.parallel({ day: function(next) { - db.sortedSetCount(set, now - terms.day, now, next); + db.sortedSetCount(set, now - terms.day, '+inf', next); }, week: function(next) { - db.sortedSetCount(set, now - terms.week, now, next); + db.sortedSetCount(set, now - terms.week, '+inf', next); }, month: function(next) { - db.sortedSetCount(set, now - terms.month, now, next); + db.sortedSetCount(set, now - terms.month, '+inf', next); }, alltime: function(next) { getGlobalField(field, next); diff --git a/src/controllers/admin/users.js b/src/controllers/admin/users.js index c68fbb8d09..3651767153 100644 --- a/src/controllers/admin/users.js +++ b/src/controllers/admin/users.js @@ -31,7 +31,7 @@ usersController.noPosts = function(req, res, next) { usersController.inactive = function(req, res, next) { var timeRange = 1000 * 60 * 60 * 24 * 30 * (parseInt(req.query.months, 10) || 3); var cutoff = Date.now() - timeRange; - getUsersByScore('users:online', 'inactive', 0, cutoff, req, res, next); + getUsersByScore('users:online', 'inactive', '-inf', cutoff, req, res, next); }; function getUsersByScore(set, section, min, max, req, res, callback) { diff --git a/src/controllers/users.js b/src/controllers/users.js index cefa6b6cc7..1eb5989c1c 100644 --- a/src/controllers/users.js +++ b/src/controllers/users.js @@ -145,7 +145,7 @@ usersController.getUsersAndCount = function(set, uid, start, stop, callback) { count: function(next) { if (set === 'users:online') { var now = Date.now(); - db.sortedSetCount('users:online', now - 300000, now, next); + db.sortedSetCount('users:online', now - 300000, '+inf', next); } else if (set === 'users:banned') { db.sortedSetCard('users:banned', next); } else { diff --git a/src/user.js b/src/user.js index 582686f774..19c60fc1fd 100644 --- a/src/user.js +++ b/src/user.js @@ -69,7 +69,7 @@ var async = require('async'), if (set === 'users:online') { var count = parseInt(stop, 10) === -1 ? stop : stop - start + 1; var now = Date.now(); - db.getSortedSetRevRangeByScore(set, start, count, now, now - 300000, callback); + db.getSortedSetRevRangeByScore(set, start, count, '+inf', now - 300000, callback); } else { db.getSortedSetRevRange(set, start, stop, callback); }