From 83d4e7efaa0e2cf571827ae9d3426117dac2fd5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Wed, 23 Sep 2020 00:59:42 -0400 Subject: [PATCH] feat: add number of posters to topic --- public/openapi/read.yaml | 3 +++ src/topics/index.js | 3 +++ 2 files changed, 6 insertions(+) diff --git a/public/openapi/read.yaml b/public/openapi/read.yaml index f0cb992675..995a610c9b 100644 --- a/public/openapi/read.yaml +++ b/public/openapi/read.yaml @@ -3542,6 +3542,9 @@ paths: type: number viewcount: type: number + posterCount: + type: number + description: The number of unique users who made a post in this topic mainPid: type: number description: The post id of the first post in this topic (also called the diff --git a/src/topics/index.js b/src/topics/index.js index a80be8b1cf..74e0395e85 100644 --- a/src/topics/index.js +++ b/src/topics/index.js @@ -146,6 +146,7 @@ Topics.getTopicWithPosts = async function (topicData, set, uid, start, stop, rev deleter, merger, related, + posterCount, ] = await Promise.all([ getMainPostAndReplies(topicData, set, uid, start, stop, reverse), categories.getCategoryData(topicData.cid), @@ -157,6 +158,7 @@ Topics.getTopicWithPosts = async function (topicData, set, uid, start, stop, rev getDeleter(topicData), getMerger(topicData), getRelated(topicData, uid), + db.sortedSetCard('tid:' + topicData.tid + ':posters'), ]); topicData.posts = posts; @@ -179,6 +181,7 @@ Topics.getTopicWithPosts = async function (topicData, set, uid, start, stop, rev topicData.mergedTimestampISO = utils.toISOString(topicData.mergedTimestamp); } topicData.related = related || []; + topicData.posterCount = posterCount; topicData.unreplied = topicData.postcount === 1; topicData.icons = [];