summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/finders/todos_finder.rb8
-rw-r--r--app/models/todo.rb1
2 files changed, 2 insertions, 7 deletions
diff --git a/app/finders/todos_finder.rb b/app/finders/todos_finder.rb
index 3243d62fc95..5d7d55180e1 100644
--- a/app/finders/todos_finder.rb
+++ b/app/finders/todos_finder.rb
@@ -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)
diff --git a/app/models/todo.rb b/app/models/todo.rb
index 3a091373329..f66755436ea 100644
--- a/app/models/todo.rb
+++ b/app/models/todo.rb
@@ -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