Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/presenters/alert_management/alert_presenter.rb')
-rw-r--r--app/presenters/alert_management/alert_presenter.rb63
1 files changed, 17 insertions, 46 deletions
diff --git a/app/presenters/alert_management/alert_presenter.rb b/app/presenters/alert_management/alert_presenter.rb
index 5bfa6dee18b..5debe6d5dbd 100644
--- a/app/presenters/alert_management/alert_presenter.rb
+++ b/app/presenters/alert_management/alert_presenter.rb
@@ -6,7 +6,10 @@ module AlertManagement
include IncidentManagement::Settings
include ActionView::Helpers::UrlHelper
- MARKDOWN_LINE_BREAK = " \n".freeze
+ MARKDOWN_LINE_BREAK = " \n"
+ HORIZONTAL_LINE = "\n\n---\n\n"
+
+ delegate :metrics_dashboard_url, :runbook, to: :parsed_payload
def initialize(alert, _attributes = {})
super
@@ -16,52 +19,37 @@ module AlertManagement
end
def issue_description
- horizontal_line = "\n\n---\n\n"
-
[
issue_summary_markdown,
alert_markdown,
incident_management_setting.issue_template_content
- ].compact.join(horizontal_line)
+ ].compact.join(HORIZONTAL_LINE)
end
def start_time
started_at&.strftime('%d %B %Y, %-l:%M%p (%Z)')
end
- def issue_summary_markdown
- <<~MARKDOWN.chomp
- #### Summary
-
- #{metadata_list}
- #{alert_details}#{metric_embed_for_alert}
- MARKDOWN
- end
-
- def runbook
- strong_memoize(:runbook) do
- payload&.dig('runbook')
- end
- end
-
- def metrics_dashboard_url; end
-
def details_url
details_project_alert_management_url(project, alert.iid)
end
+ def details
+ Gitlab::Utils::InlineHash.merge_keys(payload)
+ end
+
private
attr_reader :alert, :project
+ delegate :alert_markdown, :full_query, to: :parsed_payload
- def alerting_alert
- strong_memoize(:alerting_alert) do
- Gitlab::Alerting::Alert.new(project: project, payload: alert.payload).present
- end
+ def issue_summary_markdown
+ <<~MARKDOWN.chomp
+ #{metadata_list}
+ #{metric_embed_for_alert}
+ MARKDOWN
end
- def alert_markdown; end
-
def metadata_list
metadata = []
@@ -77,27 +65,10 @@ module AlertManagement
metadata.join(MARKDOWN_LINE_BREAK)
end
- def alert_details
- if details.present?
- <<~MARKDOWN.chomp
-
- #### Alert Details
-
- #{details_list}
- MARKDOWN
- end
- end
-
- def details_list
- alert.details
- .map { |label, value| list_item(label, value) }
- .join(MARKDOWN_LINE_BREAK)
+ def metric_embed_for_alert
+ "\n[](#{metrics_dashboard_url})" if metrics_dashboard_url
end
- def metric_embed_for_alert; end
-
- def full_query; end
-
def list_item(key, value)
"**#{key}:** #{value}".strip
end