FIX: Avoid N+1 query in `Site.json_for` (#14729)
This commit is contained in:
parent
31aa071e54
commit
c7768b6d16
|
@ -138,12 +138,11 @@ class Site
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.json_for(guardian)
|
def self.json_for(guardian)
|
||||||
|
|
||||||
if guardian.anonymous? && SiteSetting.login_required
|
if guardian.anonymous? && SiteSetting.login_required
|
||||||
return {
|
return {
|
||||||
periods: TopTopic.periods.map(&:to_s),
|
periods: TopTopic.periods.map(&:to_s),
|
||||||
filters: Discourse.filters.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)
|
UserFieldSerializer.new(userfield, root: false, scope: guardian)
|
||||||
end,
|
end,
|
||||||
auth_providers: Discourse.enabled_auth_providers.map do |provider|
|
auth_providers: Discourse.enabled_auth_providers.map do |provider|
|
||||||
|
|
Loading…
Reference in New Issue