mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-12 17:05:51 +01:00
get full topic data
This commit is contained in:
@@ -135,25 +135,12 @@ function filterAndSort(pids, data, callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getMatchedPosts(pids, data, callback) {
|
function getMatchedPosts(pids, data, callback) {
|
||||||
var postFields = ['pid', 'tid', 'timestamp', 'deleted'];
|
var postFields = ['pid', 'uid', 'tid', 'timestamp', 'deleted'];
|
||||||
var topicFields = ['deleted'];
|
|
||||||
var categoryFields = [];
|
var categoryFields = [];
|
||||||
|
|
||||||
if (data.replies) {
|
|
||||||
topicFields.push('postcount');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data.sortBy && data.sortBy !== 'relevance') {
|
if (data.sortBy && data.sortBy !== 'relevance') {
|
||||||
if (data.sortBy.startsWith('category')) {
|
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.')) {
|
|
||||||
categoryFields.push(data.sortBy.split('.')[1]);
|
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) {
|
var keys = pids.map(function (pid) {
|
||||||
return 'post:' + pid;
|
return 'post:' + pid;
|
||||||
});
|
});
|
||||||
|
|
||||||
db.getObjectsFields(keys, postFields, next);
|
db.getObjectsFields(keys, postFields, next);
|
||||||
},
|
},
|
||||||
function (_posts, next) {
|
function (_posts, next) {
|
||||||
@@ -189,14 +175,14 @@ function getMatchedPosts(pids, data, callback) {
|
|||||||
var topicKeys = posts.map(function (post) {
|
var topicKeys = posts.map(function (post) {
|
||||||
return 'topic:' + post.tid;
|
return 'topic:' + post.tid;
|
||||||
});
|
});
|
||||||
db.getObjectsFields(topicKeys, topicFields, next);
|
db.getObjects(topicKeys, next);
|
||||||
},
|
},
|
||||||
function (_topics, next) {
|
function (_topics, next) {
|
||||||
topicsData = _topics;
|
topicsData = _topics;
|
||||||
|
|
||||||
async.parallel({
|
async.parallel({
|
||||||
teasers: function (next) {
|
teasers: function (next) {
|
||||||
if (topicFields.indexOf('teaserPid') !== -1) {
|
if (data.sortBy.startsWith('teaser')) {
|
||||||
var teaserKeys = topicsData.map(function (topic) {
|
var teaserKeys = topicsData.map(function (topic) {
|
||||||
return 'post:' + topic.teaserPid;
|
return 'post:' + topic.teaserPid;
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user