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.
This commit is contained in:
Jarek Radosz 2020-10-05 10:22:55 +02:00 committed by GitHub
parent 01a9c57dcb
commit 4b5358bb42
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 0 deletions

View File

@ -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?