shuffle suggested topics, search in same category

v1.18.x
Barış Soner Uşaklı 7 years ago
parent e3966a7b8f
commit 9d3b00f778

@ -24,8 +24,8 @@ module.exports = function (Topics) {
}, next); }, next);
}, },
function (results, next) { function (results, next) {
var tids = results.tagTids.concat(results.searchTids).concat(results.categoryTids); var tids = _.shuffle(_.uniq(results.tagTids.concat(results.searchTids).concat(results.categoryTids)));
tids = _.uniq(tids).filter(function (_tid) { tids = tids.filter(function (_tid) {
return parseInt(_tid, 10) !== parseInt(tid, 10); return parseInt(_tid, 10) !== parseInt(tid, 10);
}); });
@ -59,10 +59,10 @@ module.exports = function (Topics) {
function getSearchTids(tid, callback) { function getSearchTids(tid, callback) {
async.waterfall([ async.waterfall([
function (next) { function (next) {
Topics.getTopicField(tid, 'title', next); Topics.getTopicFields(tid, ['title', 'cid'], next);
}, },
function (title, next) { function (topicData, next) {
search.searchQuery('topic', title, [], [], next); search.searchQuery('topic', topicData.title, [topicData.cid], [], next);
}, },
], callback); ], callback);
} }

Loading…
Cancel
Save