This commit is contained in:
Barış Soner Uşaklı
2016-03-29 11:26:28 +03:00
parent 879a8ba550
commit 99ae0eb378
4 changed files with 14 additions and 23 deletions

View File

@@ -77,10 +77,17 @@ usersController.banned = function(req, res, next) {
};
usersController.registrationQueue = function(req, res, next) {
var page = parseInt(req.query.page, 10) || 1;
var itemsPerPage = 20;
var start = (page - 1) * 20;
var stop = start + itemsPerPage - 1;
var invitations;
async.parallel({
registrationQueueCount: function(next) {
db.sortedSetCard('registration:queue', next);
},
users: function(next) {
user.getRegistrationQueue(0, -1, next);
user.getRegistrationQueue(start, stop, next);
},
invites: function(next) {
async.waterfall([
@@ -118,6 +125,8 @@ usersController.registrationQueue = function(req, res, next) {
if (err) {
return next(err);
}
var pageCount = Math.max(1, Math.ceil(data.registrationQueueCount / itemsPerPage));
data.pagination = pagination.create(page, pageCount);
res.render('admin/manage/registration', data);
});
};
@@ -146,7 +155,7 @@ function getUsers(set, section, req, res, next) {
var data = {
users: results.users,
page: page,
pageCount: Math.ceil(results.count / resultsPerPage)
pageCount: Math.max(1, Math.ceil(results.count / resultsPerPage))
};
data[section] = true;
render(req, res, data);