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

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

diff --git a/app/models/site.rb b/app/models/site.rb
index 4dbc2ea..b1d3dca 100644
--- a/app/models/site.rb
+++ b/app/models/site.rb
@@ -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|

GitHub sha: c7768b6d169e413e9343626adb5d688dee3fd568

This commit appears in #14729 which was merged by CvX.