diff options
author | James Lopez <james@jameslopez.es> | 2016-04-20 10:56:28 +0200 |
---|---|---|
committer | James Lopez <james@jameslopez.es> | 2016-04-20 10:56:28 +0200 |
commit | af18cddddf4ecb402ac613ddcc1f313f6adb7aad (patch) | |
tree | 02395653f7c79013b3c894e776c158f2bfeba672 /app/models/concerns | |
parent | 8619208b644f2acdc30ccf36209ac56527bb4188 (diff) | |
download | gitlab-ce-af18cddddf4ecb402ac613ddcc1f313f6adb7aad.tar.gz |
udpated a few things based on MR feedback. Also added model spec
Diffstat (limited to 'app/models/concerns')
-rw-r--r-- | app/models/concerns/issuable.rb | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/app/models/concerns/issuable.rb b/app/models/concerns/issuable.rb index e2a2899941f..d5166e81474 100644 --- a/app/models/concerns/issuable.rb +++ b/app/models/concerns/issuable.rb @@ -37,7 +37,6 @@ module Issuable scope :closed, -> { with_state(:closed) } scope :order_milestone_due_desc, -> { joins(:milestone).reorder('milestones.due_date DESC, milestones.id DESC') } scope :order_milestone_due_asc, -> { joins(:milestone).reorder('milestones.due_date ASC, milestones.id ASC') } - scope :with_label, ->(title) { joins(:labels).where(labels: { title: title }).group('issues.id').having("count(distinct labels.title) = #{title.count}") } scope :without_label, -> { joins("LEFT OUTER JOIN label_links ON label_links.target_type = '#{name}' AND label_links.target_id = #{table_name}.id").where(label_links: { id: nil }) } scope :join_project, -> { joins(:project) } @@ -122,6 +121,14 @@ module Issuable joins(join_clause).group(issuable_table[:id]).reorder("COUNT(notes.id) DESC") end + + def with_label(title) + if title.is_a?(Array) && title.count > 1 + joins(:labels).where(labels: { title: title }).group('issues.id').having("count(distinct labels.title) = #{title.count}") + else + joins(:labels).where(labels: { title: title }) + end + end end def today? |