diff options
author | Heinrich Lee Yu <hleeyu@gmail.com> | 2019-01-11 22:58:18 +0800 |
---|---|---|
committer | Heinrich Lee Yu <hleeyu@gmail.com> | 2019-01-12 00:05:36 +0800 |
commit | 2f76ff19f8f520a584a1259bd0c779e988cd7360 (patch) | |
tree | bd520f3064a21ece51da2418f2f3b67c2bacfc4f /app/finders | |
parent | 6b2f81f6078e96f081154c50dc25e54fe7c09d6f (diff) | |
download | gitlab-ce-2f76ff19f8f520a584a1259bd0c779e988cd7360.tar.gz |
Fix MilestonesFinder to pass relations to scope
Instead of querying relations into ids we just pass them to the model
scope because the scope supports it now.
Also changes other calls to `Milestone.for_projects_and_groups`
Diffstat (limited to 'app/finders')
-rw-r--r-- | app/finders/milestones_finder.rb | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/app/finders/milestones_finder.rb b/app/finders/milestones_finder.rb index 9c477978f60..fcd54b6106e 100644 --- a/app/finders/milestones_finder.rb +++ b/app/finders/milestones_finder.rb @@ -3,8 +3,8 @@ # Search for milestones # # params - Hash -# project_ids: Array of project ids or single project id. -# group_ids: Array of group ids or single group id. +# project_ids: Array of project ids or single project id or ActiveRecord relation. +# group_ids: Array of group ids or single group id or ActiveRecord relation. # order - Orders by field default due date asc. # title - filter by title. # state - filters by state. @@ -12,17 +12,13 @@ class MilestonesFinder include FinderMethods - attr_reader :params, :project_ids, :group_ids + attr_reader :params def initialize(params = {}) - @project_ids = Array(params[:project_ids]) - @group_ids = Array(params[:group_ids]) @params = params end def execute - return Milestone.none if project_ids.empty? && group_ids.empty? - items = Milestone.all items = by_groups_and_projects(items) items = by_title(items) @@ -34,7 +30,7 @@ class MilestonesFinder private def by_groups_and_projects(items) - items.for_projects_and_groups(project_ids, group_ids) + items.for_projects_and_groups(params[:project_ids], params[:group_ids]) end # rubocop: disable CodeReuse/ActiveRecord |