PERF: Fix N+1 queries in SiteSerialier. (#14365)

PERF: Fix N+1 queries in SiteSerialier. (#14365)

SiteSerializer#groups loads Group#flair_upload for each group so we need to eagerload this.

Follow-up to e8a9917db1731636f8659db63e925e743ae4ed11

diff --git a/app/models/site.rb b/app/models/site.rb
index f9ca710..4dbc2ea 100644
--- a/app/models/site.rb
+++ b/app/models/site.rb
@@ -124,7 +124,9 @@ class Site
   end
 
   def groups
-    Group.visible_groups(@guardian.user, "name ASC", include_everyone: true)
+    Group
+      .visible_groups(@guardian.user, "name ASC", include_everyone: true)
+      .includes(:flair_upload)
   end
 
   def archetypes

GitHub sha: 903439a14e1f53e0575bcdaefbeb7f215c86e02a

This commit appears in #14365 which was approved by lis2. It was merged by tgxworld.