Skip to content

Commit

Permalink
DEV: Refactor hardcoded string into a constant.
Browse files Browse the repository at this point in the history
  • Loading branch information
tgxworld committed Mar 21, 2019
1 parent 78b2c5d commit 903a09e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
1 change: 1 addition & 0 deletions app/jobs/concerns/alert_post_mixin.rb
Expand Up @@ -3,6 +3,7 @@ module AlertPostMixin

FIRING_TAG = "firing".freeze
HIGH_PRIORITY_TAG = "high-priority".freeze
NEXT_BUSINESS_DAY_SLA = "nbd".freeze

private

Expand Down
8 changes: 2 additions & 6 deletions app/jobs/regular/process_alert.rb
Expand Up @@ -58,7 +58,7 @@ def assigned_topic(receiver, params)
raw: raw,
datacenters: datacenters(alert_history),
firing: alert_history.any? { |alert| is_firing?(alert["status"]) },
high_priority: params["commonLabels"]["response_sla"] != next_business_day_sla
high_priority: params["commonLabels"]["response_sla"] != AlertPostMixin::NEXT_BUSINESS_DAY_SLA
)

assign_alert(topic, receiver) unless topic.assigned_to_user
Expand Down Expand Up @@ -98,7 +98,7 @@ def create_new_topic(receiver, params, alert_history)

tags << AlertPostMixin::FIRING_TAG.dup if is_firing?(params['status'])

if params["commonLabels"]["response_sla"] != next_business_day_sla
if params["commonLabels"]["response_sla"] != AlertPostMixin::NEXT_BUSINESS_DAY_SLA
tags << AlertPostMixin::HIGH_PRIORITY_TAG.dup
end

Expand Down Expand Up @@ -156,10 +156,6 @@ def random_group_member(id_or_name)
Group.find_by(attributes).users.sample
end

def next_business_day_sla
"nbd"
end

def assign_alert(topic, receiver, assignee: nil)
return unless SiteSetting.prometheus_alert_receiver_enable_assign

Expand Down
Expand Up @@ -99,7 +99,7 @@
end

before do
SiteSetting.queue_jobs = false
Jobs.run_immediately!
SiteSetting.tagging_enabled = true
end

Expand Down

0 comments on commit 903a09e

Please sign in to comment.