mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-17 06:52:27 +01:00
avoid N+1 for users list
This commit is contained in:
parent
d64e8a291b
commit
0bb4665b4a
@ -3,7 +3,7 @@ class API::AdminsController < API::ApiController
|
||||
|
||||
def index
|
||||
authorize :admin
|
||||
@admins = User.admins
|
||||
@admins = User.includes(profile: [:user_avatar]).admins
|
||||
end
|
||||
|
||||
def create
|
||||
|
@ -169,7 +169,7 @@ class API::MembersController < API::ApiController
|
||||
order_key = 'users.id'
|
||||
end
|
||||
|
||||
@members = User.includes(:profile, :group)
|
||||
@members = User.includes(:profile, :group, :subscriptions)
|
||||
.joins(:profile, :group, :roles, 'LEFT JOIN "subscriptions" ON "subscriptions"."user_id" = "users"."id" LEFT JOIN "plans" ON "plans"."id" = "subscriptions"."plan_id"')
|
||||
.where("users.is_active = 'true' AND roles.name = 'member'")
|
||||
.order("#{order_key} #{direction}")
|
||||
|
Loading…
x
Reference in New Issue
Block a user