diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-06-04 21:16:20 +0400 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-06-04 21:16:20 +0400 |
commit | a76bf07ae2ecaf47dab58cbeac37cb82ae8d3ad8 (patch) | |
tree | 8983bbabf91a0bacb3016eb09936116961890688 /app | |
parent | ec8d39897c76439c71b79738c5a348b36a03753b (diff) | |
parent | 181aa2b9160347ad23de3ef1e6f5ce45234261e1 (diff) |
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
Diffstat (limited to 'app')
-rw-r--r-- | app/models/concerns/mentionable.rb | 2 | ||||
-rw-r--r-- | app/models/project_team.rb | 5 |
2 files changed, 5 insertions, 2 deletions
diff --git a/app/models/concerns/mentionable.rb b/app/models/concerns/mentionable.rb index 5858fe1bb6f..a46a593c6e3 100644 --- a/app/models/concerns/mentionable.rb +++ b/app/models/concerns/mentionable.rb @@ -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 diff --git a/app/models/project_team.rb b/app/models/project_team.rb index cc8bb60aac4..afaca374130 100644 --- a/app/models/project_team.rb +++ b/app/models/project_team.rb @@ -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 |