mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-06 22:15:48 +01:00
moved getMonthlyPageViews to analytics
This commit is contained in:
@@ -66,4 +66,23 @@ var cronJob = require('cron').CronJob,
|
||||
Analytics.getUnwrittenPageviews = function() {
|
||||
return pageViews;
|
||||
};
|
||||
|
||||
Analytics.getMonthlyPageViews = function(callback) {
|
||||
var thisMonth = new Date();
|
||||
var lastMonth = new Date();
|
||||
thisMonth.setMonth(thisMonth.getMonth(), 1);
|
||||
thisMonth.setHours(0, 0, 0, 0);
|
||||
lastMonth.setMonth(thisMonth.getMonth() - 1, 1);
|
||||
lastMonth.setHours(0, 0, 0, 0);
|
||||
|
||||
var values = [thisMonth.getTime(), lastMonth.getTime()];
|
||||
|
||||
db.sortedSetScores('analytics:pageviews:month', values, function(err, scores) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
callback(null, {thisMonth: scores[0] || 0, lastMonth: scores[1] || 0});
|
||||
});
|
||||
};
|
||||
|
||||
}(exports));
|
||||
Reference in New Issue
Block a user