chore: Improve n+1 queries (#4202)

Fixes the n+1 queries that get triggered while accessing agents endpoint
This commit is contained in:
Sojan Jose
2022-03-17 15:57:32 +05:30
committed by GitHub
parent 4a3ddad02f
commit 9f8e442333
3 changed files with 5 additions and 3 deletions

View File

@@ -68,7 +68,7 @@ class Api::V1::Accounts::AgentsController < Api::V1::Accounts::BaseController
end
def agents
@agents ||= Current.account.users.order_by_full_name.includes({ avatar_attachment: [:blob] })
@agents ||= Current.account.users.order_by_full_name.includes(:account_users, { avatar_attachment: [:blob] })
end
def validate_limit