2020-05-06 08:09:36 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Mutations
|
|
|
|
module AlertManagement
|
|
|
|
class UpdateAlertStatus < Base
|
|
|
|
graphql_name 'UpdateAlertStatus'
|
|
|
|
|
|
|
|
argument :status, Types::AlertManagement::StatusEnum,
|
|
|
|
required: true,
|
|
|
|
description: 'The status to set the alert'
|
|
|
|
|
2020-11-10 07:08:57 -05:00
|
|
|
def resolve(project_path:, iid:, status:)
|
|
|
|
alert = authorized_find!(project_path: project_path, iid: iid)
|
|
|
|
result = update_status(alert, status)
|
2020-05-06 08:09:36 -04:00
|
|
|
|
2020-09-17 23:09:28 -04:00
|
|
|
track_usage_event(:incident_management_alert_status_changed, current_user.id)
|
2020-09-10 17:08:28 -04:00
|
|
|
|
2020-05-06 08:09:36 -04:00
|
|
|
prepare_response(result)
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def update_status(alert, status)
|
2020-07-08 23:09:01 -04:00
|
|
|
::AlertManagement::Alerts::UpdateService
|
|
|
|
.new(alert, current_user, status: status)
|
2020-05-12 08:09:47 -04:00
|
|
|
.execute
|
2020-05-06 08:09:36 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def prepare_response(result)
|
|
|
|
{
|
|
|
|
alert: result.payload[:alert],
|
2020-06-08 20:08:47 -04:00
|
|
|
errors: result.errors
|
2020-05-06 08:09:36 -04:00
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|