2018-11-18 11:00:15 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
module Issuable
|
|
|
|
class DestroyService < IssuableBaseService
|
|
|
|
def execute(issuable)
|
2021-04-29 21:17:54 +05:30
|
|
|
if issuable.destroy
|
|
|
|
after_destroy(issuable)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def after_destroy(issuable)
|
|
|
|
delete_todos(issuable)
|
|
|
|
issuable.update_project_counter_caches
|
|
|
|
issuable.assignees.each(&:invalidate_cache_counts)
|
|
|
|
end
|
|
|
|
|
|
|
|
def group_for(issuable)
|
|
|
|
issuable.resource_parent.group
|
|
|
|
end
|
|
|
|
|
|
|
|
def delete_todos(issuable)
|
|
|
|
actor = group_for(issuable)
|
|
|
|
|
|
|
|
if Feature.enabled?(:destroy_issuable_todos_async, actor, default_enabled: :yaml)
|
|
|
|
TodosDestroyer::DestroyedIssuableWorker
|
|
|
|
.perform_async(issuable.id, issuable.class.name)
|
|
|
|
else
|
|
|
|
TodosDestroyer::DestroyedIssuableWorker
|
|
|
|
.new
|
|
|
|
.perform(issuable.id, issuable.class.name)
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2021-04-29 21:17:54 +05:30
|
|
|
|
|
|
|
Issuable::DestroyService.prepend_if_ee('EE::Issuable::DestroyService')
|