Reduce the filters on the todos joins project query by being explicit about the join

This commit is contained in:
DJ Mountney 2016-05-25 21:31:36 -07:00
parent c3e923c496
commit 4ecc10fade
1 changed files with 7 additions and 1 deletions

View File

@ -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)