Merge pull request #9874 from kraktus/team_forum_topic_c

Fix topic count
pull/9879/head
Thibault Duplessis 2021-09-24 08:08:35 +02:00 committed by GitHub
commit 8961e18799
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -28,10 +28,11 @@ case class Categ(
def withPost(topic: Topic, post: Post): Categ =
copy(
nbTopics = if (post.troll) nbTopics else nbTopics + 1,
// the `Topic` object is created before adding the post, hence why nbPosts is compared to 0 and not to 1
nbTopics = if (post.troll || topic.nbPosts > 0) nbTopics else nbTopics + 1,
nbPosts = if (post.troll) nbPosts else nbPosts + 1,
lastPostId = if (post.troll || topic.isTooBig) lastPostId else post.id,
nbTopicsTroll = nbTopicsTroll + 1,
nbTopicsTroll = if (topic.nbPostsTroll == 0) nbTopicsTroll + 1 else nbTopicsTroll,
nbPostsTroll = nbPostsTroll + 1,
lastPostIdTroll = if (topic.isTooBig) lastPostIdTroll else post.id
)