mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-06 22:15:48 +01:00
@@ -45,7 +45,18 @@ middleware.updateLastOnlineTime = function(req, res, next) {
|
|||||||
user.updateLastOnlineTime(req.user.uid);
|
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');
|
db.sortedSetAdd('ip:recent', Date.now(), req.ip || 'Unknown');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
next();
|
next();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -188,7 +188,7 @@ SocketAdmin.analytics.get = function(socket, data, callback) {
|
|||||||
if (data.graph === 'traffic') {
|
if (data.graph === 'traffic') {
|
||||||
async.parallel({
|
async.parallel({
|
||||||
uniqueVisitors: function(next) {
|
uniqueVisitors: function(next) {
|
||||||
getHourlyStatsForSet('ip:recent', data.amount, next);
|
getHourlyStatsForSet('analytics:uniquevisitors', data.amount, next);
|
||||||
},
|
},
|
||||||
pageviews: function(next) {
|
pageviews: function(next) {
|
||||||
getHourlyStatsForSet('analytics:pageviews', data.amount, next);
|
getHourlyStatsForSet('analytics:pageviews', data.amount, next);
|
||||||
|
|||||||
Reference in New Issue
Block a user