Class: AlertManagement::CreateAlertIssueService

Inherits:
Object
  • Object
show all
Includes:
Gitlab::Utils::StrongMemoize
Defined in:
app/services/alert_management/create_alert_issue_service.rb

Instance Method Summary collapse

Methods included from Gitlab::Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Constructor Details

#initialize(alert, user) ⇒ CreateAlertIssueService

Returns a new instance of CreateAlertIssueService.

Parameters:


9
10
11
12
# File 'app/services/alert_management/create_alert_issue_service.rb', line 9

def initialize(alert, user)
  @alert = alert
  @user = user
end

Instance Method Details

#executeObject


14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/services/alert_management/create_alert_issue_service.rb', line 14

def execute
  return error_no_permissions unless allowed?
  return error_issue_already_exists if alert.issue

  result = create_incident
  return result unless result.success?

  issue = result.payload[:issue]
  return error(object_errors(alert), issue) unless associate_alert_with_issue(issue)

  SystemNoteService.new_alert_issue(alert, issue, user)

  result
end