Commit 2f55d0b6bec248cca0cd14ff2ff623ab35e1e1dc
1 parent
38d8d749
Exists in
spb-stable
and in
3 other branches
fix n+1 problem for namespaces
Showing
1 changed file
with
1 additions
and
1 deletions
Show diff stats
app/controllers/users_controller.rb
... | ... | @@ -3,7 +3,7 @@ class UsersController < ApplicationController |
3 | 3 | |
4 | 4 | def show |
5 | 5 | @user = User.find_by_username!(params[:username]) |
6 | - @projects = @user.authorized_projects.where('projects.id in (?)', current_user.authorized_projects.map(&:id)) | |
6 | + @projects = @user.authorized_projects.where(id: current_user.authorized_projects.pluck(:id)).includes(:namespace) | |
7 | 7 | @events = @user.recent_events.where(project_id: @projects.map(&:id)).limit(20) |
8 | 8 | |
9 | 9 | @title = @user.name | ... | ... |