Skip to content

Commit

Permalink
Merge pull request #4200 from coolo/optimize_watcher_query
Browse files Browse the repository at this point in the history
Fix huge bottleneck in notification emails
  • Loading branch information
Ana06 committed Dec 11, 2017
2 parents 4e6efd8 + b0d7d26 commit ccda057
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/api/app/models/event/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ def source_watchers

def find_watchers(project_key)
project_names = payload['actions'].map { |action| action[project_key] }.uniq
projects = Project.where(name: project_names).joins(watched_projects: :user)
projects.flat_map { |project| project.watched_projects.map(&:user) }
watched_projects = WatchedProject.where(project: Project.where(name: project_names))
User.where(id: watched_projects.select(:user_id))
end
end
end
end

0 comments on commit ccda057

Please sign in to comment.