mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-07 06:25:50 +01:00
Revert "feat: add reply count to getPostSummaryByPids"
This reverts commit de0f4aadb8.
This commit is contained in:
@@ -113,5 +113,3 @@ PostsObject:
|
|||||||
type: string
|
type: string
|
||||||
isMainPost:
|
isMainPost:
|
||||||
type: boolean
|
type: boolean
|
||||||
replies:
|
|
||||||
type: number
|
|
||||||
@@ -53,11 +53,6 @@ module.exports = function (Posts) {
|
|||||||
data.pid = pid;
|
data.pid = pid;
|
||||||
plugins.fireHook('action:post.setFields', { data: data });
|
plugins.fireHook('action:post.setFields', { data: data });
|
||||||
};
|
};
|
||||||
|
|
||||||
Posts.getReplyCount = async function (pid) {
|
|
||||||
// const keys = pids.map(pid => 'pid:' +pid + ':replies');
|
|
||||||
return await db.sortedSetCard(`pid:${pid}:replies`);
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
function modifyPost(post, fields) {
|
function modifyPost(post, fields) {
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ module.exports = function (Posts) {
|
|||||||
const tidToTopic = toObject('tid', topicsAndCategories.topics);
|
const tidToTopic = toObject('tid', topicsAndCategories.topics);
|
||||||
const cidToCategory = toObject('cid', topicsAndCategories.categories);
|
const cidToCategory = toObject('cid', topicsAndCategories.categories);
|
||||||
|
|
||||||
Promise.all(posts.map(async (post) => {
|
posts.forEach(function (post) {
|
||||||
// If the post author isn't represented in the retrieved users' data, then it means they were deleted, assume guest.
|
// If the post author isn't represented in the retrieved users' data, then it means they were deleted, assume guest.
|
||||||
if (!uidToUser.hasOwnProperty(post.uid)) {
|
if (!uidToUser.hasOwnProperty(post.uid)) {
|
||||||
post.uid = 0;
|
post.uid = 0;
|
||||||
@@ -47,12 +47,9 @@ module.exports = function (Posts) {
|
|||||||
post.topic = tidToTopic[post.tid];
|
post.topic = tidToTopic[post.tid];
|
||||||
post.category = post.topic && cidToCategory[post.topic.cid];
|
post.category = post.topic && cidToCategory[post.topic.cid];
|
||||||
post.isMainPost = post.topic && post.pid === post.topic.mainPid;
|
post.isMainPost = post.topic && post.pid === post.topic.mainPid;
|
||||||
post.replies = await Posts.getReplyCount(post.pid);
|
|
||||||
post.deleted = post.deleted === 1;
|
post.deleted = post.deleted === 1;
|
||||||
post.timestampISO = utils.toISOString(post.timestamp);
|
post.timestampISO = utils.toISOString(post.timestamp);
|
||||||
|
});
|
||||||
return post;
|
|
||||||
}));
|
|
||||||
|
|
||||||
posts = posts.filter(post => tidToTopic[post.tid]);
|
posts = posts.filter(post => tidToTopic[post.tid]);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user