Commit a76bf07a authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'performance-improve' into 'master'

More performance improvements for large groups

* fetch team members using much less sql queries
* collect mentioned users without iterating over all project users
parents ec8d3989 181aa2b9
......@@ -50,7 +50,7 @@ module Mentionable
matches.each do |match|
identifier = match.delete "@"
if has_project
id = project.team.members.find { |u| u.username == identifier }.try(:id)
id = project.team.members.find_by(username: identifier).try(:id)
else
id = User.where(username: identifier).pluck(:id).first
end
......
......@@ -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
......
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