summaryrefslogtreecommitdiff
path: root/app/services/task_service.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/services/task_service.rb')
-rw-r--r--app/services/task_service.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/app/services/task_service.rb b/app/services/task_service.rb
index 35d258a70c2..2c312331ae9 100644
--- a/app/services/task_service.rb
+++ b/app/services/task_service.rb
@@ -26,6 +26,15 @@ class TaskService
end
end
+ # When we mark a task as done we should:
+ #
+ # * mark all pending tasks related to the target for the user as done
+ #
+ def mark_as_done(target, user)
+ pending_tasks = pending_tasks_for(user, target.project, target)
+ pending_tasks.update_all(state: :done)
+ end
+
private
def create_task(project, target, author, user, action)
@@ -40,4 +49,8 @@ class TaskService
Task.create(attributes)
end
+
+ def pending_tasks_for(user, project, target)
+ user.tasks.pending.where(project: project, target: target)
+ end
end