blob: 6aab56f0f68a7ea511d0d1a577a32d47c61f9a30 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# frozen_string_literal: true
module Issuable
class DestroyService < IssuableBaseService
def execute(issuable)
after_destroy(issuable) if issuable.destroy
end
private
def after_destroy(issuable)
delete_associated_records(issuable)
issuable.update_project_counter_caches
issuable.assignees.each(&:invalidate_cache_counts)
end
def group_for(issuable)
issuable.resource_parent.group
end
def delete_associated_records(issuable)
actor = group_for(issuable)
delete_todos(actor, issuable)
delete_label_links(actor, issuable)
end
def delete_todos(actor, issuable)
issuable.run_after_commit_or_now do
TodosDestroyer::DestroyedIssuableWorker.perform_async(issuable.id, issuable.class.name)
end
end
def delete_label_links(actor, issuable)
issuable.run_after_commit_or_now do
Issuable::LabelLinksDestroyWorker.perform_async(issuable.id, issuable.class.name)
end
end
end
end
Issuable::DestroyService.prepend_mod_with('Issuable::DestroyService')
|