Prevent a lot of sql queries for ProjectTeam#fetch_members method

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
Dmitriy Zaporozhets 2014-06-04 19:20:25 +03:00
parent ec8d39897c
commit 0cedd7039a
No known key found for this signature in database
GPG key ID: 627C5F589F467F17

View file

@ -144,7 +144,10 @@ class ProjectTeam
group_members = group_members.send(level) if group
end
(project_members + group_members).map(&:user).uniq
user_ids = project_members.pluck(:user_id)
user_ids += group_members.pluck(:user_id) if group
User.where(id: user_ids)
end
def group