mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: don't count whispers in user stats post_count
This commit is contained in:
@@ -473,7 +473,7 @@ class PostCreator
|
|||||||
end
|
end
|
||||||
|
|
||||||
unless @post.topic.private_message?
|
unless @post.topic.private_message?
|
||||||
@user.user_stat.post_count += 1
|
@user.user_stat.post_count += 1 if @post.post_type == Post.types[:regular]
|
||||||
@user.user_stat.topic_count += 1 if @post.is_first_post?
|
@user.user_stat.topic_count += 1 if @post.is_first_post?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -390,12 +390,17 @@ describe PostCreator do
|
|||||||
topic_id: topic.id,
|
topic_id: topic.id,
|
||||||
raw: 'this is the first post').create
|
raw: 'this is the first post').create
|
||||||
|
|
||||||
|
user_stat = user.user_stat
|
||||||
|
|
||||||
whisper = PostCreator.new(user,
|
whisper = PostCreator.new(user,
|
||||||
topic_id: topic.id,
|
topic_id: topic.id,
|
||||||
reply_to_post_number: 1,
|
reply_to_post_number: 1,
|
||||||
post_type: Post.types[:whisper],
|
post_type: Post.types[:whisper],
|
||||||
raw: 'this is a whispered reply').create
|
raw: 'this is a whispered reply').create
|
||||||
|
|
||||||
|
# don't count whispers in user stats
|
||||||
|
expect(user_stat.reload.post_count).to eq(1)
|
||||||
|
|
||||||
expect(whisper).to be_present
|
expect(whisper).to be_present
|
||||||
expect(whisper.post_type).to eq(Post.types[:whisper])
|
expect(whisper.post_type).to eq(Post.types[:whisper])
|
||||||
|
|
||||||
@@ -408,6 +413,8 @@ describe PostCreator do
|
|||||||
expect(whisper_reply).to be_present
|
expect(whisper_reply).to be_present
|
||||||
expect(whisper_reply.post_type).to eq(Post.types[:whisper])
|
expect(whisper_reply.post_type).to eq(Post.types[:whisper])
|
||||||
|
|
||||||
|
expect(user_stat.reload.post_count).to eq(1)
|
||||||
|
|
||||||
# date is not precise enough in db
|
# date is not precise enough in db
|
||||||
whisper_reply.reload
|
whisper_reply.reload
|
||||||
|
|
||||||
@@ -423,10 +430,12 @@ describe PostCreator do
|
|||||||
expect(topic.posts_count).to eq(1)
|
expect(topic.posts_count).to eq(1)
|
||||||
expect(topic.highest_staff_post_number).to eq(3)
|
expect(topic.highest_staff_post_number).to eq(3)
|
||||||
|
|
||||||
topic.update_columns(highest_staff_post_number: 0,
|
topic.update_columns(
|
||||||
|
highest_staff_post_number: 0,
|
||||||
highest_post_number: 0,
|
highest_post_number: 0,
|
||||||
posts_count: 0,
|
posts_count: 0,
|
||||||
last_posted_at: 1.year.ago)
|
last_posted_at: 1.year.ago
|
||||||
|
)
|
||||||
|
|
||||||
Topic.reset_highest(topic.id)
|
Topic.reset_highest(topic.id)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user