diff options
author | Stan Hu <stanhu@gmail.com> | 2017-04-29 12:29:59 +0000 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2017-04-29 12:29:59 +0000 |
commit | 303504df4788fead8ab200dd5490658489ba5385 (patch) | |
tree | 1b913d761b84fe3251e216713c67e640967d1522 /app | |
parent | 3717d21db1b17b2e18e6843d41a2c23d006918e9 (diff) | |
download | gitlab-ce-303504df4788fead8ab200dd5490658489ba5385.tar.gz |
Revert "Merge branch 'tc-no-todo-service-select' into 'master'"revert-c3c465ac
This reverts merge request !10845
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/dashboard/todos_controller.rb | 4 | ||||
-rw-r--r-- | app/services/issuable_base_service.rb | 2 | ||||
-rw-r--r-- | app/services/todo_service.rb | 16 |
3 files changed, 9 insertions, 13 deletions
diff --git a/app/controllers/dashboard/todos_controller.rb b/app/controllers/dashboard/todos_controller.rb index 2b76e57c06a..4d7d45787fc 100644 --- a/app/controllers/dashboard/todos_controller.rb +++ b/app/controllers/dashboard/todos_controller.rb @@ -12,7 +12,7 @@ class Dashboard::TodosController < Dashboard::ApplicationController end def destroy - TodoService.new.mark_todos_as_done_by_ids(params[:id], current_user) + TodoService.new.mark_todos_as_done_by_ids([params[:id]], current_user) respond_to do |format| format.html { redirect_to dashboard_todos_path, notice: 'Todo was successfully marked as done.' } @@ -32,7 +32,7 @@ class Dashboard::TodosController < Dashboard::ApplicationController end def restore - TodoService.new.mark_todos_as_pending_by_ids(params[:id], current_user) + TodoService.new.mark_todos_as_pending_by_ids([params[:id]], current_user) render json: todos_counts end diff --git a/app/services/issuable_base_service.rb b/app/services/issuable_base_service.rb index 17cb71be5f6..b071a398481 100644 --- a/app/services/issuable_base_service.rb +++ b/app/services/issuable_base_service.rb @@ -260,7 +260,7 @@ class IssuableBaseService < BaseService todo_service.mark_todo(issuable, current_user) when 'done' todo = TodosFinder.new(current_user).execute.find_by(target: issuable) - todo_service.mark_todos_as_done_by_ids(todo, current_user) if todo + todo_service.mark_todos_as_done([todo], current_user) if todo end end 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) |