Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2017-04-29 15:29:59 +0300
committerStan Hu <stanhu@gmail.com>2017-04-29 15:29:59 +0300
commit303504df4788fead8ab200dd5490658489ba5385 (patch)
tree1b913d761b84fe3251e216713c67e640967d1522 /app/services/todo_service.rb
parent3717d21db1b17b2e18e6843d41a2c23d006918e9 (diff)
Revert "Merge branch 'tc-no-todo-service-select' into 'master'"
This reverts merge request !10845
Diffstat (limited to 'app/services/todo_service.rb')
-rw-r--r--app/services/todo_service.rb16
1 files changed, 6 insertions, 10 deletions
diff --git a/app/services/todo_service.rb b/app/services/todo_service.rb
index a19283cccd3..b6e88b0280f 100644
--- a/app/services/todo_service.rb
+++ b/app/services/todo_service.rb
@@ -170,22 +170,20 @@ class TodoService
# When user marks some todos as done
def mark_todos_as_done(todos, current_user)
- update_todos_state(todos, current_user, :done)
+ update_todos_state_by_ids(todos.select(&:id), current_user, :done)
end
def mark_todos_as_done_by_ids(ids, current_user)
- todos = todos_by_ids(ids, current_user)
- mark_todos_as_done(todos, current_user)
+ update_todos_state_by_ids(ids, current_user, :done)
end
# When user marks some todos as pending
def mark_todos_as_pending(todos, current_user)
- update_todos_state(todos, current_user, :pending)
+ update_todos_state_by_ids(todos.select(&:id), current_user, :pending)
end
def mark_todos_as_pending_by_ids(ids, current_user)
- todos = todos_by_ids(ids, current_user)
- mark_todos_as_pending(todos, current_user)
+ update_todos_state_by_ids(ids, current_user, :pending)
end
# When user marks an issue as todo
@@ -200,11 +198,9 @@ class TodoService
private
- def todos_by_ids(ids, current_user)
- current_user.todos.where(id: Array(ids))
- end
+ def update_todos_state_by_ids(ids, current_user, state)
+ todos = current_user.todos.where(id: ids)
- def update_todos_state(todos, current_user, state)
# Only update those that are not really on that state
todos = todos.where.not(state: state)
todos_ids = todos.pluck(:id)