Added highlighting and notices for moderators
- Posts and topics have an added moderation_reports function -- This is so all moderation reports can be loaded in a single query - Those moderation reports are passed into the render functions separately -- This is so the individual comments/posts don't have to be queried
This commit is contained in:
@@ -181,4 +181,9 @@ class ForumTopic < ApplicationRecord
|
||||
def update_orignal_post
|
||||
original_post&.update_columns(:updater_id => CurrentUser.id, :updated_at => Time.now)
|
||||
end
|
||||
|
||||
def moderation_reports
|
||||
posts_with_reports = posts.joins(:moderation_reports).includes(:moderation_reports).distinct
|
||||
posts_with_reports.reduce([]) {|arr,post| arr + post.moderation_reports}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1811,4 +1811,11 @@ class Post < ApplicationRecord
|
||||
|
||||
save
|
||||
end
|
||||
|
||||
def moderation_reports
|
||||
@moderation_reports ||= begin
|
||||
comments_with_reports = comments.joins(:moderation_reports).includes(:moderation_reports).distinct
|
||||
comments_with_reports.reduce([]) {|arr,comment| arr + comment.moderation_reports}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user