Class: Dri::Commands::Incidents
- Inherits:
-
Dri::Command
- Object
- Dri::Command
- Dri::Commands::Incidents
- Includes:
- Utils::Constants::Triage::Labels, Utils::Table
- Defined in:
- lib/dri/commands/incidents.rb
Constant Summary
Constants included from Utils::Constants::Triage::Labels
Utils::Constants::Triage::Labels::FAILURE, Utils::Constants::Triage::Labels::FAILURE_NEW, Utils::Constants::Triage::Labels::FOUND, Utils::Constants::Triage::Labels::INCIDENT, Utils::Constants::Triage::Labels::QA, Utils::Constants::Triage::Labels::QUALITY, Utils::Constants::Triage::Labels::QUARANTINE, Utils::Constants::Triage::Labels::SERVICE
Instance Method Summary collapse
-
#execute(_input: $stdin, output: $stdout) ⇒ Object
rubocop:disable Metrics/AbcSize.
-
#initialize(options) ⇒ Incidents
constructor
A new instance of Incidents.
Methods included from Utils::Table
Methods inherited from Dri::Command
#add_color, #api_client, #bold, #command, #cursor, #editor, #pastel, #prompt, #spinner, #verify_config_exists
Methods included from Utils::Helpers
Constructor Details
#initialize(options) ⇒ Incidents
Returns a new instance of Incidents.
10 11 12 |
# File 'lib/dri/commands/incidents.rb', line 10 def initialize() = end |
Instance Method Details
#execute(_input: $stdin, output: $stdout) ⇒ Object
rubocop:disable Metrics/AbcSize
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/dri/commands/incidents.rb', line 14 def execute(_input: $stdin, output: $stdout) # rubocop:disable Metrics/AbcSize verify_config_exists incident = add_color('Incident', :bright_yellow) service = add_color('Service', :bright_yellow) status = add_color('Status', :bright_yellow) url = add_color('URL', :bright_yellow) header = [incident, service, status, url] logger.info "Looking for open incidents..." incidents = [] spinner.run do response = api_client.incidents if response.nil? logger.info 'Hooray, no active incidents 🎉.' break end response.each do |incident| title = incident.title.truncate(70) 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 end print_table(header, incidents, alignments: [:left, :center, :center, :center]) output.puts(" Found: \#{incidents.size} incident(s).\n MSG\nend\n") |