diff options
author | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2016-09-20 06:09:57 +0300 |
---|---|---|
committer | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2016-10-19 19:58:24 +0300 |
commit | bdb7bf4b5188ffd68e54cbf671ba9ce1a4ffb1d1 (patch) | |
tree | 3f53930ff56ab0cfeceb0ab3af75fe9b75fefebd /app/models | |
parent | bf9d928b45516e716b0f7f099361ca03aa1454f8 (diff) |
List group labels on project labels page
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/label.rb | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/app/models/label.rb b/app/models/label.rb index 295c5bfaf70..f43bebbf71b 100644 --- a/app/models/label.rb +++ b/app/models/label.rb @@ -101,16 +101,16 @@ class Label < ActiveRecord::Base end end - def open_issues_count(user = nil) - issues.visible_to_user(user).opened.count + def open_issues_count(user = nil, project = nil) + issues_count(user, project_id: project.try(:id) || project_id, state: 'opened') end - def closed_issues_count(user = nil) - issues.visible_to_user(user).closed.count + def closed_issues_count(user = nil, project = nil) + issues_count(user, project_id: project.try(:id) || project_id, state: 'closed') end - def open_merge_requests_count - merge_requests.opened.count + def open_merge_requests_count(user = nil, project = nil) + merge_requests_count(user, project_id: project.try(:id) || project_id, state: 'opened') end def template? @@ -127,6 +127,18 @@ class Label < ActiveRecord::Base private + def issues_count(user, params = {}) + IssuesFinder.new(user, { label_name: title, scope: 'all' }.merge(params)) + .execute + .count + end + + def merge_requests_count(user, params = {}) + MergeRequestsFinder.new(user, { label_name: title, scope: 'all' }.merge(params)) + .execute + .count + end + def project_label? type.blank? && !template? end |