mirror of
https://github.com/discourse/discourse.git
synced 2025-01-30 06:17:47 +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
|
||||
|
||||
def user_fields
|
||||
UserField.order(:position).all
|
||||
UserField.includes(:user_field_options).order(:position).all
|
||||
end
|
||||
|
||||
def self.categories_cache_key
|
||||
|
@ -142,7 +142,7 @@ class Site
|
|||
return {
|
||||
periods: TopTopic.periods.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)
|
||||
end,
|
||||
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
|
||||
return cached_json
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
site = Site.new(guardian)
|
||||
|
|
Loading…
Reference in New Issue
Block a user