diff options
author | Paco Guzman <pacoguzmanp@gmail.com> | 2016-10-19 15:30:17 +0300 |
---|---|---|
committer | Paco Guzman <pacoguzmanp@gmail.com> | 2016-10-20 13:55:14 +0300 |
commit | 493367108eef14c8517c6d023ec46267c1e706cf (patch) | |
tree | 62ae94fac2284b8424bc4e0abbe3acdda3874982 /app/models/issue.rb | |
parent | c08435e3c25f0a7a705ed8a49b16dde176b41a40 (diff) |
Use MergeRequestsClosingIssues cache data on Issue#closed_by_merge_requests method
Diffstat (limited to 'app/models/issue.rb')
-rw-r--r-- | app/models/issue.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/app/models/issue.rb b/app/models/issue.rb index 133a5993815..89158a50353 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -211,7 +211,13 @@ class Issue < ActiveRecord::Base note.all_references(current_user, extractor: ext) end - ext.merge_requests.select { |mr| mr.open? && mr.closes_issue?(self) } + merge_requests = ext.merge_requests.select(&:open?) + if merge_requests.any? + ids = MergeRequestsClosingIssues.where(merge_request_id: merge_requests.map(&:id), issue_id: id).pluck(:merge_request_id) + merge_requests.select { |mr| mr.id.in?(ids) } + else + [] + end end def moved? |