diff options
Diffstat (limited to 'app/services/todos')
-rw-r--r-- | app/services/todos/destroy/design_service.rb | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/app/services/todos/destroy/design_service.rb b/app/services/todos/destroy/design_service.rb new file mode 100644 index 00000000000..a375d659159 --- /dev/null +++ b/app/services/todos/destroy/design_service.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +module Todos + module Destroy + # Service class for deleting todos that belongs to a deleted/archived design. + class DesignService + attr_reader :design_ids + + def initialize(design_ids) + @design_ids = design_ids + end + + def execute + todos.delete_all + end + + private + + def todos + Todo.for_target(deleted_designs.select(:design_id)).for_type(DesignManagement::Design) + end + + def deleted_designs + DesignManagement::Action.by_design(design_ids).by_event(:deletion) + end + end + end +end |