lib/dri/report.rb in dri-0.6.1 vs lib/dri/report.rb in dri-0.7.0

- old
+ new

@@ -2,24 +2,41 @@ module Dri class Report # rubocop:disable Metrics/ClassLength using Refinements - attr_reader :header, :failures, :labels + attr_reader :header, :failures, :labels, :labels_incidents, :incidents def initialize(config) @labels = ['Title', 'Issue', 'Pipelines', 'Stack Trace', 'Actions'] + @labels_incidents = %w[Incident Service Status URL] @failures = [] + @incidents = [] @date = Date.today @today = Date.today.strftime("%Y-%m-%d") @weekday = Date.today.strftime("%A") @header = nil @api_client = ApiClient.new(config) end def set_header(timezone, username) @header = "# #{timezone}, #{@weekday} - #{@date}\n posted by: @#{username}" + end + + def add_incident(incident) + title = incident["title"] + url = incident["web_url"] + labels = incident["labels"] + status = 'N/A' + service = 'N/A' + + labels.each do |label| + status = label.gsub!('Incident::', ' ').to_s if label.include? "Incident::" + service = label.gsub!('Service::', ' ').to_s if label.include? "Service::" + end + + @incidents << [title, service, status, url] end def add_failure(failure, actions_opts = []) iid = failure["iid"] title = format_title(failure["title"])