FIX: Properly avoid n+1 query on flagged posts

This code was in here previously but some columns were included that
were not used.
This commit is contained in:
Robin Ward 2018-06-14 09:22:42 -04:00
parent c82887a0f0
commit 4a4406de8c
1 changed files with 4 additions and 7 deletions

View File

@ -21,15 +21,12 @@ class FlaggedUserSerializer < BasicUserSerializer
def custom_fields
fields = User.whitelisted_user_custom_fields(scope)
if scope.can_edit?(object)
fields += DiscoursePluginRegistry.serialized_current_user_fields.to_a
result = {}
fields.each do |k|
result[k] = object.custom_fields[k] if object.custom_fields[k].present?
end
if fields.present?
User.custom_fields_for_ids([object.id], fields)[object.id] || {}
else
{}
end
result
end
end