mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-29 18:16:17 +01:00
fix performance issue with acp
This commit is contained in:
@@ -81,13 +81,13 @@ function getStatsForSet(set, field, callback) {
|
|||||||
var now = Date.now();
|
var now = Date.now();
|
||||||
async.parallel({
|
async.parallel({
|
||||||
day: function(next) {
|
day: function(next) {
|
||||||
db.sortedSetCount(set, now - terms.day, now, next);
|
db.sortedSetCount(set, now - terms.day, '+inf', next);
|
||||||
},
|
},
|
||||||
week: function(next) {
|
week: function(next) {
|
||||||
db.sortedSetCount(set, now - terms.week, now, next);
|
db.sortedSetCount(set, now - terms.week, '+inf', next);
|
||||||
},
|
},
|
||||||
month: function(next) {
|
month: function(next) {
|
||||||
db.sortedSetCount(set, now - terms.month, now, next);
|
db.sortedSetCount(set, now - terms.month, '+inf', next);
|
||||||
},
|
},
|
||||||
alltime: function(next) {
|
alltime: function(next) {
|
||||||
getGlobalField(field, next);
|
getGlobalField(field, next);
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ usersController.noPosts = function(req, res, next) {
|
|||||||
usersController.inactive = function(req, res, next) {
|
usersController.inactive = function(req, res, next) {
|
||||||
var timeRange = 1000 * 60 * 60 * 24 * 30 * (parseInt(req.query.months, 10) || 3);
|
var timeRange = 1000 * 60 * 60 * 24 * 30 * (parseInt(req.query.months, 10) || 3);
|
||||||
var cutoff = Date.now() - timeRange;
|
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) {
|
function getUsersByScore(set, section, min, max, req, res, callback) {
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ usersController.getUsersAndCount = function(set, uid, start, stop, callback) {
|
|||||||
count: function(next) {
|
count: function(next) {
|
||||||
if (set === 'users:online') {
|
if (set === 'users:online') {
|
||||||
var now = Date.now();
|
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') {
|
} else if (set === 'users:banned') {
|
||||||
db.sortedSetCard('users:banned', next);
|
db.sortedSetCard('users:banned', next);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ var async = require('async'),
|
|||||||
if (set === 'users:online') {
|
if (set === 'users:online') {
|
||||||
var count = parseInt(stop, 10) === -1 ? stop : stop - start + 1;
|
var count = parseInt(stop, 10) === -1 ? stop : stop - start + 1;
|
||||||
var now = Date.now();
|
var now = Date.now();
|
||||||
db.getSortedSetRevRangeByScore(set, start, count, now, now - 300000, callback);
|
db.getSortedSetRevRangeByScore(set, start, count, '+inf', now - 300000, callback);
|
||||||
} else {
|
} else {
|
||||||
db.getSortedSetRevRange(set, start, stop, callback);
|
db.getSortedSetRevRange(set, start, stop, callback);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user