fix performance issue with acp

v1.18.x
Barış Soner Uşaklı 9 years ago
parent bd6d44aeaa
commit 53249de799

@ -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);

@ -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) {

@ -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 {

@ -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);
}

Loading…
Cancel
Save