Commit 0d6374ac authored by Jacopo's avatar Jacopo

Uses .includes(:user).references(:user) only when needed

parent 42f78e91
......@@ -13,16 +13,15 @@ module API
def find_all_members(source_type, source)
members = (source_type == 'project') ? find_all_members_for_project(source) : find_all_members_for_group(source)
members.references(:user).
non_invite.
non_request.
select(%w[members.expires_at members.access_level users.*])
members.non_invite.
non_request
end
def find_all_members_for_project(project)
shared_group_ids = project.project_group_links.pluck(:group_id)
source_ids = [project.id, project.group&.id].concat(shared_group_ids).compact
Member.includes(user: :project_authorizations).
Member.includes(:user).
joins(user: :project_authorizations).
where(project_authorizations: { project_id: project.id }).
where(source_id: source_ids)
end
......
......@@ -39,7 +39,7 @@ module API
source = find_source(source_type, params[:id])
members = find_all_members(source_type, source)
members = members.merge(User.search(params[:query])) if params[:query].present?
members = members.references(:user).merge(User.search(params[:query])) if params[:query].present?
members = paginate(members)
present members, with: Entities::Member
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment