Welcome to mirror list, hosted at ThFree Co, Russian Federation.

destroy_service.rb « issuable « services « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d5aa84d8d6c6850ac97675e9f0801a9573ad5c3b (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
# frozen_string_literal: true

module Issuable
  class DestroyService < IssuableBaseService
    def execute(issuable)
      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)
      end
    end
  end
end

Issuable::DestroyService.prepend_if_ee('EE::Issuable::DestroyService')