2020-05-24 23:13:21 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Mutations
|
|
|
|
module AlertManagement
|
|
|
|
class UpdateAlertStatus < Base
|
|
|
|
graphql_name 'UpdateAlertStatus'
|
|
|
|
|
|
|
|
argument :status, Types::AlertManagement::StatusEnum,
|
|
|
|
required: true,
|
2021-10-27 15:23:28 +05:30
|
|
|
description: 'Status to set the alert.'
|
2020-05-24 23:13:21 +05:30
|
|
|
|
2021-01-29 00:20:46 +05:30
|
|
|
def resolve(project_path:, iid:, status:)
|
|
|
|
alert = authorized_find!(project_path: project_path, iid: iid)
|
|
|
|
result = update_status(alert, status)
|
2020-05-24 23:13:21 +05:30
|
|
|
|
2023-03-04 22:38:38 +05:30
|
|
|
track_alert_events('incident_management_alert_status_changed', alert)
|
2020-11-24 15:15:51 +05:30
|
|
|
|
2020-05-24 23:13:21 +05:30
|
|
|
prepare_response(result)
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def update_status(alert, status)
|
2020-07-28 23:09:34 +05:30
|
|
|
::AlertManagement::Alerts::UpdateService
|
|
|
|
.new(alert, current_user, status: status)
|
2020-05-24 23:13:21 +05:30
|
|
|
.execute
|
|
|
|
end
|
|
|
|
|
|
|
|
def prepare_response(result)
|
|
|
|
{
|
|
|
|
alert: result.payload[:alert],
|
2020-06-23 00:09:42 +05:30
|
|
|
errors: result.errors
|
2020-05-24 23:13:21 +05:30
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|