mirror of
https://github.com/discourse/discourse.git
synced 2025-05-28 01:22:17 +08:00
FEATURE: Count only approved flagged posts in user pages (#22799)
FEATURE: Only approved flags for post counters * Why was this change necessary? The counters for flagged posts in the user's profile and user index from the admin view include flags that were rejected, ignored or pending review. This introduces unnecessary noise. Also the flagged posts counter in the user's profile includes custom flags which add further noise to this signal. * How does it address the problem? * Modifying User#flags_received_count to return posts with only approved standard flags * Refactoring User#number_of_flagged_posts to alias to User#flags_received_count * Updating the flagged post staff counter hyperlink to navigate to a filtered view of that user's approved flagged posts to maintain consistency with the counter * Adding system tests for the profile page to cover the flagged posts staff counter
This commit is contained in:
@ -1202,13 +1202,6 @@ class User < ActiveRecord::Base
|
||||
user_warnings.count
|
||||
end
|
||||
|
||||
def flags_received_count
|
||||
posts
|
||||
.includes(:post_actions)
|
||||
.where("post_actions.post_action_type_id" => PostActionType.flag_types_without_custom.values)
|
||||
.count
|
||||
end
|
||||
|
||||
def private_topics_count
|
||||
topics_allowed.where(archetype: Archetype.private_message).count
|
||||
end
|
||||
@ -1539,8 +1532,14 @@ class User < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def number_of_flagged_posts
|
||||
ReviewableFlaggedPost.where(target_created_by: self.id).count
|
||||
posts
|
||||
.with_deleted
|
||||
.includes(:post_actions)
|
||||
.where("post_actions.post_action_type_id" => PostActionType.flag_types_without_custom.values)
|
||||
.where("post_actions.agreed_at IS NOT NULL")
|
||||
.count
|
||||
end
|
||||
alias_method :flags_received_count, :number_of_flagged_posts
|
||||
|
||||
def number_of_rejected_posts
|
||||
ReviewableQueuedPost.rejected.where(target_created_by_id: self.id).count
|
||||
|
Reference in New Issue
Block a user