From a1c3d40739ed133e1ca1cd9191628acf938809cf Mon Sep 17 00:00:00 2001 From: Jacopo Date: Wed, 3 Oct 2018 13:00:03 +0200 Subject: Allows to filter issues by `Any milestone` in the API In GET `api/v4/projects/:id/issues` the user can filter issues that have an assigned milestone through the parameter `milestone=Any+Milestone`. --- app/finders/issuable_finder.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'app/finders') diff --git a/app/finders/issuable_finder.rb b/app/finders/issuable_finder.rb index 0209a1397b9..794c2f293c4 100644 --- a/app/finders/issuable_finder.rb +++ b/app/finders/issuable_finder.rb @@ -424,6 +424,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 @@ -433,6 +437,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) -- cgit v1.2.1