From 76db0dc115316e53ed7d2189cc8789f0a0cef3c2 Mon Sep 17 00:00:00 2001 From: Ahmad Sherif Date: Fri, 12 Aug 2016 15:52:58 +0200 Subject: [PATCH] Pass project IDs relation to ProjectsFinder instead of using a block --- app/finders/projects_finder.rb | 4 ++-- app/finders/todos_finder.rb | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/app/finders/projects_finder.rb b/app/finders/projects_finder.rb index 56877b6d75a..c7911736812 100644 --- a/app/finders/projects_finder.rb +++ b/app/finders/projects_finder.rb @@ -1,7 +1,7 @@ class ProjectsFinder < UnionFinder - def execute(current_user = nil, options = {}, &block) + def execute(current_user = nil, project_ids_relation = nil) segments = all_projects(current_user) - segments.map!(&block) if block + segments.map! { |s| s.where(id: project_ids_relation) } if project_ids_relation find_union(segments, Project) end diff --git a/app/finders/todos_finder.rb b/app/finders/todos_finder.rb index 9b24a86e1c1..4fe0070552e 100644 --- a/app/finders/todos_finder.rb +++ b/app/finders/todos_finder.rb @@ -95,9 +95,7 @@ class TodosFinder def projects(items) item_project_ids = items.reorder(nil).select(:project_id) - ProjectsFinder.new.execute(current_user) do |relation| - relation.where(id: item_project_ids) - end + ProjectsFinder.new.execute(current_user, item_project_ids) end def type?