get full topic data

v1.18.x
Baris Usakli 8 years ago
parent 982184740d
commit f6ba79287b

@ -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;
});

Loading…
Cancel
Save