mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-06 14:05:46 +01:00
@@ -45,7 +45,18 @@ middleware.updateLastOnlineTime = function(req, res, next) {
|
||||
user.updateLastOnlineTime(req.user.uid);
|
||||
}
|
||||
|
||||
db.sortedSetScore('ip:recent', req.ip, function(err, score) {
|
||||
if (err) {
|
||||
return;
|
||||
}
|
||||
var today = new Date();
|
||||
today.setHours(today.getHours(), 0, 0, 0);
|
||||
|
||||
if (!score || score < today.getTime()) {
|
||||
db.sortedSetIncrBy('analytics:uniquevisitors', 1, today.getTime());
|
||||
db.sortedSetAdd('ip:recent', Date.now(), req.ip || 'Unknown');
|
||||
}
|
||||
});
|
||||
|
||||
next();
|
||||
};
|
||||
|
||||
@@ -188,7 +188,7 @@ SocketAdmin.analytics.get = function(socket, data, callback) {
|
||||
if (data.graph === 'traffic') {
|
||||
async.parallel({
|
||||
uniqueVisitors: function(next) {
|
||||
getHourlyStatsForSet('ip:recent', data.amount, next);
|
||||
getHourlyStatsForSet('analytics:uniquevisitors', data.amount, next);
|
||||
},
|
||||
pageviews: function(next) {
|
||||
getHourlyStatsForSet('analytics:pageviews', data.amount, next);
|
||||
|
||||
Reference in New Issue
Block a user