From 4e663998afba78724f536a9c17ea628cf66fa6de Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Fri, 23 Sep 2016 12:44:08 +0800 Subject: [PATCH] PERF: N+1 query on user summary page. --- app/controllers/users_controller.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 6baa28bda0a..17f9763777c 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -33,7 +33,11 @@ class UsersController < ApplicationController def show raise Discourse::InvalidAccess if SiteSetting.hide_user_profiles_from_public && !current_user - @user = fetch_user_from_params(include_inactive: current_user.try(:staff?)) + @user = fetch_user_from_params( + { include_inactive: current_user.try(:staff?) }, + [{ user_profile: :card_image_badge }] + ) + user_serializer = UserSerializer.new(@user, scope: guardian, root: 'user') # TODO remove this options from serializer