display user post topic stats in admin index

v1.18.x
barisusakli 11 years ago
parent 684f858415
commit e6c9647acf

@ -50,19 +50,6 @@ define('forum/admin/index', function() {
socket.emit('admin.restart');
});
socket.emit('admin.getVisitorCount', function(err, data) {
if(err) {
return app.alertError(err.message);
}
var uniqueVisitors = $('#unique-visitors');
for(var key in data) {
if (data.hasOwnProperty(key)) {
uniqueVisitors.find('#' + key).text(data[key]);
}
}
});
};
Admin.updateRoomUsage = function(err, data) {

@ -34,14 +34,70 @@ var adminController = {
};
adminController.home = function(req, res, next) {
res.render('admin/index', {
version: pkg.version,
emailerInstalled: plugins.hasListeners('action:email.send'),
searchInstalled: plugins.hasListeners('filter:search.query'),
restartRequired: meta.restartRequired
getStats(function(err, stats) {
if (err) {
return next(err);
}
res.render('admin/index', {
version: pkg.version,
emailerInstalled: plugins.hasListeners('action:email.send'),
searchInstalled: plugins.hasListeners('filter:search.query'),
restartRequired: meta.restartRequired,
stats: stats
});
});
};
function getStats(callback) {
async.parallel([
function(next) {
getStatsForSet('ip:recent', next);
},
function(next) {
getStatsForSet('users:joindate', next);
},
function(next) {
getStatsForSet('posts:pid', next);
},
function(next) {
getStatsForSet('topics:tid', next);
}
], function(err, results) {
if (err) {
return callback(err);
}
results[0].name = 'Unique Visitors';
results[1].name = 'Users';
results[2].name = 'Posts';
results[3].name = 'Topics';
callback(null, results);
});
}
function getStatsForSet(set, callback) {
var terms = {
day: 86400000,
week: 604800000,
month: 2592000000
};
var now = Date.now();
async.parallel({
day: function(next) {
db.sortedSetCount(set, now - terms.day, now, next);
},
week: function(next) {
db.sortedSetCount(set, now - terms.week, now, next);
},
month: function(next) {
db.sortedSetCount(set, now - terms.month, now, next);
},
alltime: function(next) {
db.sortedSetCount(set, 0, now, next);
}
}, callback);
}
adminController.categories.active = function(req, res, next) {
filterAndRenderCategories(req, res, next, true);
};

@ -39,29 +39,6 @@ SocketAdmin.restart = function(socket, data, callback) {
meta.restart();
};
SocketAdmin.getVisitorCount = function(socket, data, callback) {
var terms = {
day: 86400000,
week: 604800000,
month: 2592000000
};
var now = Date.now();
async.parallel({
day: function(next) {
db.sortedSetCount('ip:recent', now - terms.day, now, next);
},
week: function(next) {
db.sortedSetCount('ip:recent', now - terms.week, now, next);
},
month: function(next) {
db.sortedSetCount('ip:recent', now - terms.month, now, next);
},
alltime: function(next) {
db.sortedSetCount('ip:recent', 0, now, next);
}
}, callback);
};
SocketAdmin.fireEvent = function(socket, data, callback) {
index.server.sockets.emit(data.name, data.payload || {});
};

Loading…
Cancel
Save