summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2018-10-05 08:21:32 +0000
committerDouwe Maan <douwe@gitlab.com>2018-10-05 08:21:32 +0000
commit1e9003f4a42fa75b25045701fec5e9aa32cae71a (patch)
treeb6d02f78aba4d5ceae29b8f3c5ae7321ebc5de19 /app
parent3c8ccd2eda593205de8edde5102249372a1ed3a2 (diff)
parenta1c3d40739ed133e1ca1cd9191628acf938809cf (diff)
downloadgitlab-ce-1e9003f4a42fa75b25045701fec5e9aa32cae71a.tar.gz
Merge branch '51748-filter-any-milestone-via-api' into 'master'
Allows to filter issues by `Any milestone` in the API Closes #51748 See merge request gitlab-org/gitlab-ce!22080
Diffstat (limited to 'app')
-rw-r--r--app/finders/issuable_finder.rb6
-rw-r--r--app/models/concerns/issuable.rb1
2 files changed, 7 insertions, 0 deletions
diff --git a/app/finders/issuable_finder.rb b/app/finders/issuable_finder.rb
index 9e24154e4b6..17e9b59b355 100644
--- a/app/finders/issuable_finder.rb
+++ b/app/finders/issuable_finder.rb
@@ -428,6 +428,10 @@ class IssuableFinder
params[:milestone_title] == Milestone::Upcoming.name
end
+ def filter_by_any_milestone?
+ params[:milestone_title] == Milestone::Any.title
+ end
+
def filter_by_started_milestone?
params[:milestone_title] == Milestone::Started.name
end
@@ -437,6 +441,8 @@ class IssuableFinder
if milestones?
if filter_by_no_milestone?
items = items.left_joins_milestones.where(milestone_id: [-1, nil])
+ elsif filter_by_any_milestone?
+ items = items.any_milestone
elsif filter_by_upcoming_milestone?
upcoming_ids = Milestone.upcoming_ids_by_projects(projects(items))
items = items.left_joins_milestones.where(milestone_id: upcoming_ids)
diff --git a/app/models/concerns/issuable.rb b/app/models/concerns/issuable.rb
index 5f65fceb7af..2aa52bbaeea 100644
--- a/app/models/concerns/issuable.rb
+++ b/app/models/concerns/issuable.rb
@@ -76,6 +76,7 @@ module Issuable
scope :recent, -> { reorder(id: :desc) }
scope :of_projects, ->(ids) { where(project_id: ids) }
scope :of_milestones, ->(ids) { where(milestone_id: ids) }
+ scope :any_milestone, -> { where('milestone_id IS NOT NULL') }
scope :with_milestone, ->(title) { left_joins_milestones.where(milestones: { title: title }) }
scope :opened, -> { with_state(:opened) }
scope :only_opened, -> { with_state(:opened) }