mirror of
https://github.com/discourse/discourse.git
synced 2025-06-01 02:04:53 +08:00
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:

committed by
GitHub

parent
51a31f7835
commit
b876ff6281
@ -11,6 +11,7 @@ describe UserStatCountUpdater do
|
||||
before do
|
||||
@orig_logger = Rails.logger
|
||||
Rails.logger = @fake_logger = FakeLogger.new
|
||||
SiteSetting.verbose_user_stat_count_logging = true
|
||||
end
|
||||
|
||||
after do
|
||||
@ -21,9 +22,11 @@ describe UserStatCountUpdater do
|
||||
UserStatCountUpdater.decrement!(post, user_stat: user_stat)
|
||||
|
||||
expect(@fake_logger.warnings.last).to match("topic_count")
|
||||
expect(@fake_logger.warnings.last).to match(post.id.to_s)
|
||||
|
||||
UserStatCountUpdater.decrement!(post_2, user_stat: user_stat)
|
||||
|
||||
expect(@fake_logger.warnings.last).to match("post_count")
|
||||
expect(@fake_logger.warnings.last).to match(post_2.id.to_s)
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user