Fix N+1 queries on identity in UsersController and BoardsController (#2365)
* Fix N+1 queries on identity in UsersController and BoardsController - Add .includes(:identity) to UsersController#index - Add .includes(creator: :identity) to BoardsController#index - Add N+1 regression tests for both controllers * Simplify controller N+1 tests with query assertions --------- Co-authored-by: Mike Dalessio <mike@37signals.com>
This commit is contained in:
@@ -5,7 +5,7 @@ class BoardsController < ApplicationController
|
||||
before_action :ensure_permission_to_admin_board, only: %i[ update destroy ]
|
||||
|
||||
def index
|
||||
set_page_and_extract_portion_from Current.user.boards.ordered_by_recently_accessed
|
||||
set_page_and_extract_portion_from Current.user.boards.ordered_by_recently_accessed.includes(creator: :identity)
|
||||
fresh_when etag: @page.records
|
||||
end
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ class UsersController < ApplicationController
|
||||
before_action :ensure_permission_to_change_user, only: %i[ update destroy ]
|
||||
|
||||
def index
|
||||
set_page_and_extract_portion_from Current.account.users.active.alphabetically
|
||||
set_page_and_extract_portion_from Current.account.users.active.alphabetically.includes(:identity)
|
||||
end
|
||||
|
||||
def show
|
||||
|
||||
Reference in New Issue
Block a user