FIX: Update user stat counts when post/topic visibility changes. (#15883)

Breakdown of fixes in this commit:

* `UserStat#topic_count` was not updated when visibility of
the topic changed.

* `UserStat#post_count` was not updated when post was hidden or
unhidden.

* `TopicConverter` was only incrementing or decrementing the counts by 1
even if a user has multiple posts in the topic.

* The commit turns off the verbose logging by default as it is just
noise to normal users who are not debugging this problem.
This commit is contained in:
Alan Guo Xiang Tan
2022-02-11 09:00:58 +08:00
committed by GitHub
parent 51a31f7835
commit b876ff6281
15 changed files with 204 additions and 61 deletions

View File

@ -603,7 +603,9 @@ class PostCreator
@user.user_stat.update!(first_post_created_at: @post.created_at)
end
UserStatCountUpdater.increment!(@post)
if !@post.hidden || @post.topic.visible
UserStatCountUpdater.increment!(@post)
end
if !@topic.private_message? && @post.post_type != Post.types[:whisper]
@user.update(last_posted_at: @post.created_at)