From f6ba79287bccd9bfade5d72711d414b1995584b7 Mon Sep 17 00:00:00 2001 From: Baris Usakli Date: Thu, 8 Jun 2017 14:12:07 -0400 Subject: [PATCH] get full topic data --- src/search.js | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/src/search.js b/src/search.js index 6fe103015c..4ad633438f 100644 --- a/src/search.js +++ b/src/search.js @@ -135,25 +135,12 @@ function filterAndSort(pids, data, callback) { } function getMatchedPosts(pids, data, callback) { - var postFields = ['pid', 'tid', 'timestamp', 'deleted']; - var topicFields = ['deleted']; + var postFields = ['pid', 'uid', 'tid', 'timestamp', 'deleted']; var categoryFields = []; - if (data.replies) { - topicFields.push('postcount'); - } - if (data.sortBy && data.sortBy !== 'relevance') { - if (data.sortBy.startsWith('category')) { - topicFields.push('cid'); - } else if (data.sortBy.startsWith('topic.')) { - topicFields.push(data.sortBy.split('.')[1]); - } else if (data.sortBy.startsWith('user.')) { - postFields.push('uid'); - } else if (data.sortBy.startsWith('category.')) { + if (data.sortBy.startsWith('category.')) { categoryFields.push(data.sortBy.split('.')[1]); - } else if (data.sortBy.startsWith('teaser')) { - topicFields.push('teaserPid'); } } @@ -163,7 +150,6 @@ function getMatchedPosts(pids, data, callback) { var keys = pids.map(function (pid) { return 'post:' + pid; }); - db.getObjectsFields(keys, postFields, next); }, function (_posts, next) { @@ -189,14 +175,14 @@ function getMatchedPosts(pids, data, callback) { var topicKeys = posts.map(function (post) { return 'topic:' + post.tid; }); - db.getObjectsFields(topicKeys, topicFields, next); + db.getObjects(topicKeys, next); }, function (_topics, next) { topicsData = _topics; async.parallel({ teasers: function (next) { - if (topicFields.indexOf('teaserPid') !== -1) { + if (data.sortBy.startsWith('teaser')) { var teaserKeys = topicsData.map(function (topic) { return 'post:' + topic.teaserPid; });