mirror of
https://github.com/discourse/discourse.git
synced 2025-01-31 06:09:30 +08:00
FIX: Avoid another N+1 query in Site.json_for
(#14763)
A follow-up to #14729, this time for logged-in users and/or non-login-required sites.
This commit is contained in:
parent
deee715a2c
commit
85d0ddb9eb
|
@ -32,7 +32,7 @@ class Site
|
||||||
end
|
end
|
||||||
|
|
||||||
def user_fields
|
def user_fields
|
||||||
UserField.order(:position).all
|
UserField.includes(:user_field_options).order(:position).all
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.categories_cache_key
|
def self.categories_cache_key
|
||||||
|
@ -142,7 +142,7 @@ class Site
|
||||||
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.includes(:user_field_options).all.map do |userfield|
|
user_fields: UserField.includes(:user_field_options).order(:position).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|
|
||||||
|
@ -161,7 +161,6 @@ class Site
|
||||||
if cached_json && seq == cached_seq.to_i && Discourse.git_version == cached_version
|
if cached_json && seq == cached_seq.to_i && Discourse.git_version == cached_version
|
||||||
return cached_json
|
return cached_json
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
site = Site.new(guardian)
|
site = Site.new(guardian)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user