Class: QaServer::ScenarioRunHistory
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- QaServer::ScenarioRunHistory
- Defined in:
- app/models/qa_server/scenario_run_history.rb
Overview
rubocop:disable Metrics/ClassLength
Constant Summary collapse
- GOOD_MARKER =
'√'- BAD_MARKER =
'X'- UNKNOWN_MARKER =
'?'
Class Method Summary collapse
-
.historical_summary(force: false) ⇒ Object
Get a summary level of historical data.
-
.run_failures(run_id:, force: false) ⇒ Object
Get set of failures for a run, if any.
-
.run_results(run_id:, authority_name: nil, status: nil, url: nil) ⇒ Object
deprecated
Deprecated.
Not used anywhere. Being removed.
-
.run_summary(scenario_run:, force: false) ⇒ Object
Get a summary of passing/failing tests for a run.
-
.save_result(run_id:, scenario_result:) ⇒ Object
Save a scenario result.
Class Method Details
.historical_summary(force: false) ⇒ Object
Get a summary level of historical data
140 141 142 143 144 145 146 147 148 149 150 151 152 |
# File 'app/models/qa_server/scenario_run_history.rb', line 140 def self.historical_summary(force: false) Rails.cache.fetch("#{self.class}/#{__method__}", expires_in: QaServer.cache_expiry, race_condition_ttl: 1.hour, force: force) do Rails.logger.info("#{self.class}##{__method__} - calculating pass/fail per authority across all time - cache expired or refresh requested (#{force})") runs = failures = return [] unless runs.present? data = [] runs.each do |auth_name, run_count| data << (failures, auth_name, run_count) end data end end |
.run_failures(run_id:, force: false) ⇒ Object
Get set of failures for a run, if any.
127 128 129 130 131 132 133 |
# File 'app/models/qa_server/scenario_run_history.rb', line 127 def self.run_failures(run_id:, force: false) return [] unless run_id Rails.cache.fetch("#{self.class}/#{__method__}", expires_in: QaServer.cache_expiry, race_condition_ttl: 1.hour, force: force) do Rails.logger.info("#{self.class}##{__method__} - finding failures in latest run - cache expired or refresh requested (#{force})") QaServer::ScenarioRunHistory.where(scenario_run_registry_id: run_id).where.not(status: :good).to_a end end |
.run_results(run_id:, authority_name: nil, status: nil, url: nil) ⇒ Object
Deprecated.
Not used anywhere. Being removed.
Get set of all scenario results for a run.
93 94 95 96 97 98 99 100 101 |
# File 'app/models/qa_server/scenario_run_history.rb', line 93 def self.run_results(run_id:, authority_name: nil, status: nil, url: nil) return [] unless run_id where = {} where[:scenario_run_registry_id] = run_id where[:authority_name] = if .present? where[:status] = status if status.present? where[:url] = url if url.present? QaServer::ScenarioRunHistory.where(where).to_a end |
.run_summary(scenario_run:, force: false) ⇒ Object
Get a summary of passing/failing tests for a run.
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'app/models/qa_server/scenario_run_history.rb', line 45 def self.run_summary(scenario_run:, force: false) Rails.cache.fetch("#{self.class}/#{__method__}", expires_in: QaServer.cache_expiry, race_condition_ttl: 1.hour, force: force) do Rails.logger.info("#{self.class}##{__method__} - creating summary of latest run - cache expired or refresh requested (#{force})") status = status_counts_in_run(run_id: scenario_run.id) summary_class.new(run_id: scenario_run.id, run_dt_stamp: scenario_run.dt_stamp, authority_count: (run_id: scenario_run.id).count, failing_authority_count: (run_id: scenario_run.id).count, passing_scenario_count: status['good'], failing_scenario_count: status['bad'] + status['unknown']) end end |
.save_result(run_id:, scenario_result:) ⇒ Object
Save a scenario result
21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/models/qa_server/scenario_run_history.rb', line 21 def self.save_result(run_id:, scenario_result:) QaServer::ScenarioRunHistory.create(scenario_run_registry_id: run_id, status: scenario_result[:status], authority_name: scenario_result[:authority_name], subauthority_name: scenario_result[:subauthority_name], service: scenario_result[:service], action: scenario_result[:action], url: scenario_result[:url], err_message: scenario_result[:err_message], run_time: scenario_result[:run_time]) end |