diff options
author | blackst0ne <blackst0ne.ru@gmail.com> | 2017-02-16 23:03:42 +0300 |
---|---|---|
committer | blackst0ne <blackst0ne.ru@gmail.com> | 2017-02-16 23:03:42 +0300 |
commit | 905fdfba927dcfa32b99d649521a52445bc6838f (patch) | |
tree | 2c71c618cf675dfc92147d592866b1742f5adf79 /app/models/merge_requests_closing_issues.rb | |
parent | f02210ca068050f032354b48304cd73d968fb4d8 (diff) |
Add merge request count to each issue on issues list
Diffstat (limited to 'app/models/merge_requests_closing_issues.rb')
-rw-r--r-- | app/models/merge_requests_closing_issues.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/app/models/merge_requests_closing_issues.rb b/app/models/merge_requests_closing_issues.rb index ab597c37947..1ecdfd1dfdb 100644 --- a/app/models/merge_requests_closing_issues.rb +++ b/app/models/merge_requests_closing_issues.rb @@ -4,4 +4,12 @@ class MergeRequestsClosingIssues < ActiveRecord::Base validates :merge_request_id, uniqueness: { scope: :issue_id }, presence: true validates :issue_id, presence: true + + class << self + def count_for_collection(ids) + select('issue_id', 'COUNT(*) as count'). + group(:issue_id). + where(issue_id: ids) + end + end end |