mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: New site setting min_flags_staff_visibility
When set higher than 1, flags won't show up for staff in the admin section unless the minimum threshold of flags on a post is reached.
This commit is contained in:
@@ -52,13 +52,22 @@ class PostAction < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def self.update_flagged_posts_count
|
||||
posts_flagged_count = PostAction.active
|
||||
flagged_relation = PostAction.active
|
||||
.flags
|
||||
.joins(post: :topic)
|
||||
.where('posts.deleted_at' => nil)
|
||||
.where('topics.deleted_at' => nil)
|
||||
.where('posts.user_id > 0')
|
||||
.count('DISTINCT posts.id')
|
||||
.group("posts.id")
|
||||
|
||||
if SiteSetting.min_flags_staff_visibility > 1
|
||||
flagged_relation = flagged_relation
|
||||
.having("count(*) >= ?", SiteSetting.min_flags_staff_visibility)
|
||||
end
|
||||
|
||||
posts_flagged_count = flagged_relation
|
||||
.pluck("posts.id")
|
||||
.count
|
||||
|
||||
$redis.set('posts_flagged_count', posts_flagged_count)
|
||||
user_ids = User.staff.pluck(:id)
|
||||
|
||||
Reference in New Issue
Block a user