FIX: Avoid N+1 query in Site.json_for (#14729)

This commit is contained in:
Jarek Radosz 2021-10-26 22:46:53 +02:00 committed by GitHub
parent 31aa071e54
commit c7768b6d16
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -138,12 +138,11 @@ class Site
end
def self.json_for(guardian)
if guardian.anonymous? && SiteSetting.login_required
return {
periods: TopTopic.periods.map(&:to_s),
filters: Discourse.filters.map(&:to_s),
user_fields: UserField.all.map do |userfield|
user_fields: UserField.includes(:user_field_options).all.map do |userfield|
UserFieldSerializer.new(userfield, root: false, scope: guardian)
end,
auth_providers: Discourse.enabled_auth_providers.map do |provider|