Class: QaServer::ScenarioRunHistory
- Inherits:
-
ApplicationRecord
- Object
- ApplicationRecord
- 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 ⇒ Object
Get a summary of the number of days passing/failing for scenario runs during configured time period.
-
.run_failures(run_id:) ⇒ Object
Get set of failures for a run, if any.
-
.run_summary(scenario_run:) ⇒ 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 ⇒ Object
Get a summary of the number of days passing/failing for scenario runs during configured time period
89 90 91 92 93 94 95 96 97 98 |
# File 'app/models/qa_server/scenario_run_history.rb', line 89 def historical_summary days_good = count_days(:good) days_bad = count_days(:bad) days_unknown = count_days(:unknown) keys = (days_good.keys + days_bad.keys + days_unknown.keys).uniq.sort keys.each_with_object({}) do |auth, hash| next unless auth hash[auth] = { good: day_count(auth, days_good), bad: day_count(auth, days_bad) + day_count(auth, days_unknown) } end end |
.run_failures(run_id:) ⇒ Object
Get set of failures for a run, if any.
79 80 81 82 |
# File 'app/models/qa_server/scenario_run_history.rb', line 79 def run_failures(run_id:) return [] unless run_id QaServer::ScenarioRunHistory.where(scenario_run_registry_id: run_id).where.not(status: :good).to_a end |
.run_summary(scenario_run:) ⇒ Object
Get a summary of passing/failing tests for a run.
47 48 49 50 51 52 53 54 55 |
# File 'app/models/qa_server/scenario_run_history.rb', line 47 def run_summary(scenario_run:) 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 |
.save_result(run_id:, scenario_result:) ⇒ Object
Save a scenario result
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/models/qa_server/scenario_run_history.rb', line 22 def save_result(run_id:, scenario_result:) registry = QaServer::ScenarioRunRegistry.find(run_id) 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], date: registry.dt_stamp.to_date) end |