summaryrefslogtreecommitdiff
path: root/app/services/incident_management/issuable_escalation_statuses/build_service.rb
blob: 9ebcf72a0c9a8ade27b1bc7ca1f8236e1cd13084 (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
# frozen_string_literal: true

module IncidentManagement
  module IssuableEscalationStatuses
    class BuildService < ::BaseProjectService
      def initialize(issue)
        @issue = issue
        @alert = issue.alert_management_alert

        super(project: issue.project)
      end

      def execute
        return issue.escalation_status if issue.escalation_status

        issue.build_incident_management_issuable_escalation_status(alert_params)
      end

      private

      attr_reader :issue, :alert

      def alert_params
        return {} unless alert

        {
          status_event: alert.status_event_for(alert.status_name)
        }
      end
    end
  end
end

IncidentManagement::IssuableEscalationStatuses::BuildService.prepend_mod