Commit b69e3a04 authored by Sean Arnold's avatar Sean Arnold

Rename some variables

- Prevent extra SQL query
- Fix spelling error
parent 6b5c7c91
......@@ -35,7 +35,7 @@ module AlertManagement
create_alert_management_alert
end
create_incident
process_incident_alert
end
def reset_alert_management_alert_status
......@@ -49,16 +49,17 @@ module AlertManagement
end
def create_alert_management_alert
am_alert = AlertManagement::Alert.new(am_alert_params.merge(ended_at: nil))
if am_alert.save
am_alert.execute_services
new_alert = AlertManagement::Alert.new(am_alert_params.merge(ended_at: nil))
if new_alert.save
new_alert.execute_services
@am_alert = new_alert
return
end
logger.warn(
message: 'Unable to create AlertManagement::Alert',
project_id: project.id,
alert_errors: am_alert.errors.messages
alert_errors: new_alert.errors.messages
)
end
......@@ -91,8 +92,7 @@ module AlertManagement
SystemNoteService.auto_resolve_prometheus_alert(issue, project, User.alert_bot) if issue.reset.closed?
end
def create_incident
clear_memoization(:am_alert) if am_alert.blank?
def process_incident_alert
return unless am_alert
return if am_alert.issue
......
......@@ -105,7 +105,7 @@ FactoryBot.define do
{
annotations: {
title: 'This is a prometheus error',
summary: 'Summary of the erorr',
summary: 'Summary of the error',
description: 'Description of the error'
},
startsAt: started_at
......
......@@ -84,7 +84,7 @@ RSpec.describe AlertManagement::ProcessPrometheusAlertService do
context 'when alert can be created' do
it_behaves_like 'creates an alert management alert'
it 'creates an incident issue' do
it 'processes the incident alert' do
expect(IncidentManagement::ProcessAlertWorker)
.to receive(:perform_async)
.with(nil, nil, kind_of(Integer))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment