debian-mirror-gitlab/app/services/issuable/destroy_service.rb

41 lines
995 B
Ruby
Raw Normal View History

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-06-08 01:23:25 +05:30
after_destroy(issuable) if issuable.destroy
2021-04-29 21:17:54 +05:30
end
private
def after_destroy(issuable)
2021-06-08 01:23:25 +05:30
delete_associated_records(issuable)
2021-04-29 21:17:54 +05:30
issuable.update_project_counter_caches
issuable.assignees.each(&:invalidate_cache_counts)
end
def group_for(issuable)
issuable.resource_parent.group
end
2021-06-08 01:23:25 +05:30
def delete_associated_records(issuable)
2021-04-29 21:17:54 +05:30
actor = group_for(issuable)
2021-06-08 01:23:25 +05:30
delete_todos(actor, issuable)
delete_label_links(actor, issuable)
end
def delete_todos(actor, issuable)
TodosDestroyer::DestroyedIssuableWorker
.perform_async(issuable.id, issuable.class.name)
end
def delete_label_links(actor, issuable)
Issuable::LabelLinksDestroyWorker
.perform_async(issuable.id, issuable.class.name)
2018-03-17 18:26:18 +05:30
end
end
end
2021-04-29 21:17:54 +05:30
2021-06-08 01:23:25 +05:30
Issuable::DestroyService.prepend_mod_with('Issuable::DestroyService')