From 4ecc10fade61a1b45cd45ea4189e95a2acbea353 Mon Sep 17 00:00:00 2001 From: DJ Mountney Date: Wed, 25 May 2016 21:31:36 -0700 Subject: [PATCH] Reduce the filters on the todos joins project query by being explicit about the join --- app/finders/todos_finder.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/finders/todos_finder.rb b/app/finders/todos_finder.rb index f638b5bf91f..3243d62fc95 100644 --- a/app/finders/todos_finder.rb +++ b/app/finders/todos_finder.rb @@ -23,7 +23,13 @@ class TodosFinder end def execute - items = current_user.todos.joins(:project).where(projects: { pending_delete: false }) + items = current_user.todos + + # Filter out todos linked to project pending deletion + items = items.joins( + 'INNER JOIN projects ON projects.id = todos.project_id AND projects.pending_delete = false' + ) + items = by_action_id(items) items = by_author(items) items = by_project(items)