From e0c7d65a929691652aa3bf91d23ba867485a0e0c Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Thu, 27 Aug 2020 14:44:51 -0400 Subject: [PATCH] Revert "feat: add reply count to getPostSummaryByPids" This reverts commit de0f4aadb8075fc6e84c4389f281c39e5f4f611d. --- public/openapi/components/schemas/PostsObject.yaml | 4 +--- src/posts/data.js | 5 ----- src/posts/summary.js | 7 ++----- 3 files changed, 3 insertions(+), 13 deletions(-) diff --git a/public/openapi/components/schemas/PostsObject.yaml b/public/openapi/components/schemas/PostsObject.yaml index ed546b052a..2c6595c1ca 100644 --- a/public/openapi/components/schemas/PostsObject.yaml +++ b/public/openapi/components/schemas/PostsObject.yaml @@ -112,6 +112,4 @@ PostsObject: nullable: true type: string isMainPost: - type: boolean - replies: - type: number \ No newline at end of file + type: boolean \ No newline at end of file diff --git a/src/posts/data.js b/src/posts/data.js index 4d7edac799..bc4ba790d1 100644 --- a/src/posts/data.js +++ b/src/posts/data.js @@ -53,11 +53,6 @@ module.exports = function (Posts) { data.pid = pid; 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) { diff --git a/src/posts/summary.js b/src/posts/summary.js index 60d2305cea..ad3258076a 100644 --- a/src/posts/summary.js +++ b/src/posts/summary.js @@ -38,7 +38,7 @@ module.exports = function (Posts) { const tidToTopic = toObject('tid', topicsAndCategories.topics); 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 (!uidToUser.hasOwnProperty(post.uid)) { post.uid = 0; @@ -47,12 +47,9 @@ module.exports = function (Posts) { post.topic = tidToTopic[post.tid]; post.category = post.topic && cidToCategory[post.topic.cid]; post.isMainPost = post.topic && post.pid === post.topic.mainPid; - post.replies = await Posts.getReplyCount(post.pid); post.deleted = post.deleted === 1; post.timestampISO = utils.toISOString(post.timestamp); - - return post; - })); + }); posts = posts.filter(post => tidToTopic[post.tid]);