From 4b5358bb42f90c9ae77f102239b7a3b9cfb9a461 Mon Sep 17 00:00:00 2001 From: Jarek Radosz Date: Mon, 5 Oct 2020 10:22:55 +0200 Subject: [PATCH] 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. --- app/controllers/groups_controller.rb | 1 + 1 file changed, 1 insertion(+) 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?