mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-08 15:05:46 +01:00
read total from global object
This commit is contained in:
@@ -70,16 +70,16 @@ adminController.home = function(req, res, next) {
|
||||
function getStats(callback) {
|
||||
async.parallel([
|
||||
function(next) {
|
||||
getStatsForSet('ip:recent', next);
|
||||
getStatsForSet('ip:recent', 'uniqueIPCount', next);
|
||||
},
|
||||
function(next) {
|
||||
getStatsForSet('users:joindate', next);
|
||||
getStatsForSet('users:joindate', 'userCount', next);
|
||||
},
|
||||
function(next) {
|
||||
getStatsForSet('posts:pid', next);
|
||||
getStatsForSet('posts:pid', 'postCount', next);
|
||||
},
|
||||
function(next) {
|
||||
getStatsForSet('topics:tid', next);
|
||||
getStatsForSet('topics:tid', 'topicCount', next);
|
||||
}
|
||||
], function(err, results) {
|
||||
if (err) {
|
||||
@@ -94,12 +94,13 @@ function getStats(callback) {
|
||||
});
|
||||
}
|
||||
|
||||
function getStatsForSet(set, callback) {
|
||||
function getStatsForSet(set, field, callback) {
|
||||
var terms = {
|
||||
day: 86400000,
|
||||
week: 604800000,
|
||||
month: 2592000000
|
||||
};
|
||||
|
||||
var now = Date.now();
|
||||
async.parallel({
|
||||
day: function(next) {
|
||||
@@ -112,7 +113,7 @@ function getStatsForSet(set, callback) {
|
||||
db.sortedSetCount(set, now - terms.month, now, next);
|
||||
},
|
||||
alltime: function(next) {
|
||||
db.sortedSetCount(set, 0, now, next);
|
||||
db.getObjectField('global', field, next);
|
||||
}
|
||||
}, callback);
|
||||
}
|
||||
|
||||
@@ -51,7 +51,9 @@ middleware.updateLastOnlineTime = function(req, res, next) {
|
||||
}
|
||||
var today = new Date();
|
||||
today.setHours(today.getHours(), 0, 0, 0);
|
||||
|
||||
if (!score) {
|
||||
db.incrObjectField('global', 'uniqueIPCount');
|
||||
}
|
||||
if (!score || score < today.getTime()) {
|
||||
db.sortedSetIncrBy('analytics:uniquevisitors', 1, today.getTime());
|
||||
db.sortedSetAdd('ip:recent', Date.now(), req.ip || 'Unknown');
|
||||
|
||||
Reference in New Issue
Block a user