Skip to content

A platform for community discussion. Free, open, simple.

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

Jarek Radosz4b5358bb42f9
diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb
index 273fe25c2b2..75be316516a 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?