FIX: Preload uploads in groups#search to stop N+1 (#10814)

FIX: Preload uploads in groups#search to stop N+1 (#10814)

BasicGroupSerializer includes flair_url which uses flair_upload relation, so the N in N+1 in this case was the number of groups with flair in the forum.

diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb
index 273fe25..75be316 100644
--- a/app/controllers/groups_controller.rb
+++ b/app/controllers/groups_controller.rb
@@ -537,6 +537,7 @@ class GroupsController < ApplicationController
   def search
     groups = Group.visible_groups(current_user)
       .where("groups.id <> ?", Group::AUTO_GROUPS[:everyone])
+      .includes(:flair_upload)
       .order(:name)
 
     if (term = params[:term]).present?

GitHub sha: 4b5358bb

This commit appears in #10814 which was approved by ZogStriP. It was merged by CvX.