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

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

module IncidentManagement
  module IssuableEscalationStatuses
    class CreateService < BaseService
      def initialize(issue)
        @issue = issue
        @alert = issue.alert_management_alert
      end

      def execute
        escalation_status = ::IncidentManagement::IssuableEscalationStatus.new(issue: issue, **alert_params)

        if escalation_status.save
          ServiceResponse.success(payload: { escalation_status: escalation_status })
        else
          ServiceResponse.error(message: escalation_status.errors&.full_messages)
        end
      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::CreateService.prepend_mod