v1.18.x
Baris Usakli 8 years ago
parent a2a5fb9928
commit 1d26fc0d89

@ -13,7 +13,7 @@ module.exports = function (Categories) {
plugins.fireHook('filter:category.topics.prepare', data, next); plugins.fireHook('filter:category.topics.prepare', data, next);
}, },
function (data, next) { function (data, next) {
Categories.getTopicIds(data.cid, data.set, data.reverse, data.start, data.stop, next); Categories.getTopicIds(data, next);
}, },
function (tids, next) { function (tids, next) {
topics.getTopicsByTids(tids, data.uid, next); topics.getTopicsByTids(tids, data.uid, next);
@ -35,14 +35,18 @@ module.exports = function (Categories) {
], callback); ], callback);
}; };
Categories.getTopicIds = function (cid, set, reverse, start, stop, callback) { Categories.getTopicIds = function (data, callback) {
var pinnedTids; var pinnedTids;
var pinnedCount; var pinnedCount;
var totalPinnedCount; var totalPinnedCount;
var start = data.start;
var stop = data.stop;
var set = data.set;
async.waterfall([ async.waterfall([
function (next) { function (next) {
Categories.getPinnedTids(cid, 0, -1, next); Categories.getPinnedTids(data.cid, 0, -1, next);
}, },
function (_pinnedTids, next) { function (_pinnedTids, next) {
totalPinnedCount = _pinnedTids.length; totalPinnedCount = _pinnedTids.length;
@ -64,9 +68,9 @@ module.exports = function (Categories) {
stop = stop === -1 ? stop : start + normalTidsToGet - 1; stop = stop === -1 ? stop : start + normalTidsToGet - 1;
if (Array.isArray(set)) { if (Array.isArray(set)) {
db[reverse ? 'getSortedSetRevIntersect' : 'getSortedSetIntersect']({ sets: set, start: start, stop: stop }, next); db[data.reverse ? 'getSortedSetRevIntersect' : 'getSortedSetIntersect']({ sets: set, start: start, stop: stop }, next);
} else { } else {
db[reverse ? 'getSortedSetRevRange' : 'getSortedSetRange'](set, start, stop, next); db[data.reverse ? 'getSortedSetRevRange' : 'getSortedSetRange'](set, start, stop, next);
} }
}, },
function (normalTids, next) { function (normalTids, next) {

Loading…
Cancel
Save