|
|
@ -4,19 +4,23 @@ var async = require('async');
|
|
|
|
var posts = require('../../posts');
|
|
|
|
var posts = require('../../posts');
|
|
|
|
var user = require('../../user');
|
|
|
|
var user = require('../../user');
|
|
|
|
var analytics = require('../../analytics');
|
|
|
|
var analytics = require('../../analytics');
|
|
|
|
|
|
|
|
var pagination = require('../../pagination');
|
|
|
|
|
|
|
|
|
|
|
|
var flagsController = {};
|
|
|
|
var flagsController = {};
|
|
|
|
|
|
|
|
|
|
|
|
flagsController.get = function(req, res, next) {
|
|
|
|
flagsController.get = function(req, res, next) {
|
|
|
|
var sortBy = req.query.sortBy || 'count';
|
|
|
|
var sortBy = req.query.sortBy || 'count';
|
|
|
|
var byUsername = req.query.byUsername || '';
|
|
|
|
var byUsername = req.query.byUsername || '';
|
|
|
|
var start = 0;
|
|
|
|
|
|
|
|
var stop = 19;
|
|
|
|
var page = parseInt(req.query.page, 10) || 1;
|
|
|
|
|
|
|
|
var itemsPerPage = 20;
|
|
|
|
|
|
|
|
var start = (page - 1) * itemsPerPage;
|
|
|
|
|
|
|
|
var stop = start + itemsPerPage - 1;
|
|
|
|
|
|
|
|
|
|
|
|
async.waterfall([
|
|
|
|
async.waterfall([
|
|
|
|
function (next) {
|
|
|
|
function (next) {
|
|
|
|
async.parallel({
|
|
|
|
async.parallel({
|
|
|
|
posts: function(next) {
|
|
|
|
flagData: function(next) {
|
|
|
|
if (byUsername) {
|
|
|
|
if (byUsername) {
|
|
|
|
posts.getUserFlags(byUsername, sortBy, req.uid, start, stop, next);
|
|
|
|
posts.getUserFlags(byUsername, sortBy, req.uid, start, stop, next);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -27,7 +31,9 @@ flagsController.get = function(req, res, next) {
|
|
|
|
analytics: function(next) {
|
|
|
|
analytics: function(next) {
|
|
|
|
analytics.getDailyStatsForSet('analytics:flags', Date.now(), 30, next);
|
|
|
|
analytics.getDailyStatsForSet('analytics:flags', Date.now(), 30, next);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
assignees: async.apply(user.getAdminsandGlobalMods)
|
|
|
|
assignees: function(next) {
|
|
|
|
|
|
|
|
user.getAdminsandGlobalMods(next);
|
|
|
|
|
|
|
|
}
|
|
|
|
}, next);
|
|
|
|
}, next);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
], function (err, results) {
|
|
|
|
], function (err, results) {
|
|
|
@ -49,12 +55,15 @@ flagsController.get = function(req, res, next) {
|
|
|
|
return userObj;
|
|
|
|
return userObj;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var pageCount = Math.max(1, Math.ceil(results.flagData.count / itemsPerPage));
|
|
|
|
|
|
|
|
|
|
|
|
var data = {
|
|
|
|
var data = {
|
|
|
|
posts: results.posts,
|
|
|
|
posts: results.flagData.posts,
|
|
|
|
assignees: results.assignees,
|
|
|
|
assignees: results.assignees,
|
|
|
|
analytics: results.analytics,
|
|
|
|
analytics: results.analytics,
|
|
|
|
next: stop + 1,
|
|
|
|
next: stop + 1,
|
|
|
|
byUsername: byUsername,
|
|
|
|
byUsername: byUsername,
|
|
|
|
|
|
|
|
pagination: pagination.create(page, pageCount, req.query),
|
|
|
|
title: '[[pages:flagged-posts]]'
|
|
|
|
title: '[[pages:flagged-posts]]'
|
|
|
|
};
|
|
|
|
};
|
|
|
|
res.render('admin/manage/flags', data);
|
|
|
|
res.render('admin/manage/flags', data);
|
|
|
|