diff options
author | Sean McGivern <sean@gitlab.com> | 2018-10-02 15:39:46 +0300 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2018-10-04 16:27:36 +0300 |
commit | 819ecd5fb01ab64cacc31253c51984a7564949d7 (patch) | |
tree | dd9a64ff81186105161950715c1e9ab1b3d1b2e6 /app/models/concerns/subscribable.rb | |
parent | eac20b74a7e92c34a42fe0658b745521cf2e862f (diff) |
Fix N+1 for notification recipients in subscribers
Diffstat (limited to 'app/models/concerns/subscribable.rb')
-rw-r--r-- | app/models/concerns/subscribable.rb | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/app/models/concerns/subscribable.rb b/app/models/concerns/subscribable.rb index 1d0a61364b0..92a5c1112af 100644 --- a/app/models/concerns/subscribable.rb +++ b/app/models/concerns/subscribable.rb @@ -31,9 +31,11 @@ module Subscribable end def subscribers(project) - subscriptions_available(project) - .where(subscribed: true) - .map(&:user) + relation = subscriptions_available(project) + .where(subscribed: true) + .select(:user_id) + + User.where(id: relation) end def toggle_subscription(user, project = nil) |