mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-08 16:42:48 +01:00
user search paginator
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
var async = require('async'),
|
||||
meta = require('../meta'),
|
||||
user = require('../user'),
|
||||
pagination = require('../pagination'),
|
||||
db = require('../database');
|
||||
|
||||
module.exports = function(User) {
|
||||
@@ -49,23 +50,19 @@ module.exports = function(User) {
|
||||
},
|
||||
function(userData, next) {
|
||||
|
||||
var pages = [];
|
||||
if (matchCount > resultsPerPage) {
|
||||
pageCount = Math.ceil(matchCount / resultsPerPage);
|
||||
var currentPage = Math.max(1, Math.ceil((start + 1) / resultsPerPage));
|
||||
for(var i=1; i<=pageCount; ++i) {
|
||||
pages.push({page: i, active: i === currentPage});
|
||||
}
|
||||
}
|
||||
|
||||
var diff = process.hrtime(startTime);
|
||||
var timing = (diff[0] * 1e3 + diff[1] / 1e6).toFixed(1);
|
||||
next(null, {
|
||||
var data = {
|
||||
timing: timing,
|
||||
users: userData,
|
||||
matchCount: matchCount,
|
||||
pages: pages
|
||||
});
|
||||
matchCount: matchCount
|
||||
};
|
||||
|
||||
var currentPage = Math.max(1, Math.ceil((start + 1) / resultsPerPage));
|
||||
pageCount = Math.ceil(matchCount / resultsPerPage);
|
||||
pagination.create(currentPage, pageCount, data);
|
||||
|
||||
next(null, data);
|
||||
}
|
||||
], callback);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user