moved getMonthlyPageViews to analytics

v1.18.x
barisusakli 10 years ago
parent 235a981dd1
commit aeb15ed7ee

@ -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));

@ -233,7 +233,7 @@ SocketAdmin.analytics.get = function(socket, data, callback) {
getHourlyStatsForSet('analytics:pageviews', data.amount, next);
},
monthlyPageViews: function(next) {
getMonthlyPageViews(next);
analytics.getMonthlyPageViews(next);
}
}, function(err, data) {
data.pastDay = data.pageviews.reduce(function(a, b) {return parseInt(a, 10) + parseInt(b, 10);});
@ -286,24 +286,6 @@ function getHourlyStatsForSet(set, hours, callback) {
});
}
function getMonthlyPageViews(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});
});
}
SocketAdmin.getMoreEvents = function(socket, next, callback) {
var start = parseInt(next, 10);
if (start < 0) {

Loading…
Cancel
Save