提交 4280575f 编写于 作者: D DJ Mountney

Move filtering todos by projects not pending deletion into a scope on the todo model

上级 4ecc10fa
......@@ -23,13 +23,7 @@ class TodosFinder
end
def execute
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 = current_user.todos.not_pending_delete
items = by_action_id(items)
items = by_author(items)
items = by_project(items)
......
......@@ -19,6 +19,7 @@ class Todo < ActiveRecord::Base
scope :pending, -> { with_state(:pending) }
scope :done, -> { with_state(:done) }
scope :not_pending_delete, -> { joins('INNER JOIN projects ON projects.id = todos.project_id AND projects.pending_delete = false') }
state_machine :state, initial: :pending do
event :done do
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册