mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 03:55:55 +01:00
only call sortedSetCard if using pagination
This commit is contained in:
@@ -275,11 +275,14 @@ function getFromUserSet(tpl, set, method, type, req, res, next) {
|
|||||||
|
|
||||||
var page = Math.max(1, parseInt(req.query.page, 10) || 1);
|
var page = Math.max(1, parseInt(req.query.page, 10) || 1);
|
||||||
var itemsPerPage = (tpl === 'account/topics' || tpl === 'account/watched') ? results.settings.topicsPerPage : results.settings.postsPerPage;
|
var itemsPerPage = (tpl === 'account/topics' || tpl === 'account/watched') ? results.settings.topicsPerPage : results.settings.postsPerPage;
|
||||||
itemsPerPage = parseInt(itemsPerPage, 10);
|
|
||||||
|
|
||||||
async.parallel({
|
async.parallel({
|
||||||
count: function(next) {
|
itemCount: function(next) {
|
||||||
db.sortedSetCard(setName, next);
|
if (results.settings.usePagination) {
|
||||||
|
db.sortedSetCard(setName, next);
|
||||||
|
} else {
|
||||||
|
next(null, 0);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
data: function(next) {
|
data: function(next) {
|
||||||
var start = (page - 1) * itemsPerPage;
|
var start = (page - 1) * itemsPerPage;
|
||||||
@@ -293,7 +296,7 @@ function getFromUserSet(tpl, set, method, type, req, res, next) {
|
|||||||
|
|
||||||
userData[type] = results.data[type];
|
userData[type] = results.data[type];
|
||||||
userData.nextStart = results.data.nextStart;
|
userData.nextStart = results.data.nextStart;
|
||||||
var pageCount = Math.ceil(results.count / itemsPerPage);
|
var pageCount = Math.ceil(results.itemCount / itemsPerPage);
|
||||||
|
|
||||||
var pagination = require('../pagination');
|
var pagination = require('../pagination');
|
||||||
userData.pagination = pagination.create(page, pageCount);
|
userData.pagination = pagination.create(page, pageCount);
|
||||||
|
|||||||
Reference in New Issue
Block a user