Class: QaServer::MonitorStatusPresenter
- Inherits:
-
Object
- Object
- QaServer::MonitorStatusPresenter
- Defined in:
- app/presenters/qa_server/monitor_status_presenter.rb
Overview
rubocop:disable Metrics/ClassLength
Constant Summary collapse
- HISTORICAL_AUTHORITY_NAME_IDX =
0- HISTORICAL_FAILURE_COUNT_IDX =
1- HISTORICAL_PASSING_COUNT_IDX =
2- PERFORMANCE_FOR_DAY_KEY =
performance_history_class::PERFORMANCE_FOR_DAY_KEY
- PERFORMANCE_BY_HOUR_KEY =
performance_history_class::PERFORMANCE_BY_HOUR_KEY
- PERFORMANCE_FOR_MONTH_KEY =
performance_history_class::PERFORMANCE_FOR_MONTH_KEY
- PERFORMANCE_BY_DAY_KEY =
performance_history_class::PERFORMANCE_BY_DAY_KEY
- PERFORMANCE_FOR_YEAR_KEY =
performance_history_class::PERFORMANCE_FOR_YEAR_KEY
- PERFORMANCE_BY_MONTH_KEY =
performance_history_class::PERFORMANCE_BY_MONTH_KEY
- LOAD_TIME_KEY =
performance_history_class::LOAD_TIME_KEY
- NORMALIZATION_TIME_KEY =
performance_history_class::NORMALIZATION_TIME_KEY
- COMBINED_TIME_KEY =
performance_history_class::COMBINED_TIME_KEY
Instance Method Summary collapse
-
#authorities_count ⇒ Integer
Number of loaded authorities.
-
#authorities_count_style ⇒ String
Css style class representing whether all tests passed or any failed.
- #days_authority_failing(historical_entry) ⇒ Object
- #days_authority_passing(historical_entry) ⇒ Object
- #days_authority_tested(historical_entry) ⇒ Object
- #display_historical_datatable? ⇒ Boolean
- #display_historical_graph? ⇒ Boolean
- #display_history_details? ⇒ Boolean
-
#failing_authorities_count ⇒ Integer
Number of authorities with failing tests in the latest test run.
-
#failing_tests_count ⇒ Integer
Number of failing tests in the latest test run.
-
#failing_tests_style ⇒ String
Css style class representing whether all tests passed or any failed.
- #failure_style_class(historical_entry) ⇒ Object
-
#failures ⇒ Array<Hash>
A list of failures data in the latest test run, if any.
-
#failures? ⇒ Boolean
True if failure data exists for the latest test run; otherwise false.
-
#first_updated ⇒ String
Date of first recorded test run.
- #historical_data_authority_name(historical_entry) ⇒ Object
- #historical_graph ⇒ Object
-
#historical_summary ⇒ Array<Hash>
Historical test data to be displayed (authname, failing, passing).
-
#history? ⇒ Boolean
True if historical test data exists; otherwise false.
-
#initialize(current_summary:, current_failure_data:, historical_summary_data:, performance_data:) ⇒ MonitorStatusPresenter
constructor
A new instance of MonitorStatusPresenter.
-
#last_updated ⇒ String
Date of last test run.
- #passing_style_class(historical_entry) ⇒ Object
-
#passing_tests_count ⇒ Integer
Number of passing tests in the latest test run.
- #percent_authority_failing(historical_entry) ⇒ Object
- #percent_authority_failing_str(historical_entry) ⇒ Object
- #performance_data? ⇒ Boolean
- #performance_for_day_graph ⇒ Object
- #performance_for_month_graph ⇒ Object
- #performance_for_year_graph ⇒ Object
-
#status_label(status) ⇒ String
The name of the css style class to use for the status cell based on the status of the scenario test.
-
#status_style_class(status) ⇒ String
The name of the css style class to use for the status cell based on the status of the scenario test.
-
#tests_count ⇒ Integer
Number of tests in the latest test run.
Constructor Details
#initialize(current_summary:, current_failure_data:, historical_summary_data:, performance_data:) ⇒ MonitorStatusPresenter
Returns a new instance of MonitorStatusPresenter.
30 31 32 33 34 35 |
# File 'app/presenters/qa_server/monitor_status_presenter.rb', line 30 def initialize(current_summary:, current_failure_data:, historical_summary_data:, performance_data:) @current_summary = current_summary @current_failure_data = current_failure_data @historical_summary_data = historical_summary_data @performance_data = performance_data end |
Instance Method Details
#authorities_count ⇒ Integer
Returns number of loaded authorities.
48 49 50 |
# File 'app/presenters/qa_server/monitor_status_presenter.rb', line 48 def @current_summary. end |
#authorities_count_style ⇒ String
Returns css style class representing whether all tests passed or any failed.
58 59 60 |
# File 'app/presenters/qa_server/monitor_status_presenter.rb', line 58 def failures? ? 'status-bad' : 'status-good' end |
#days_authority_failing(historical_entry) ⇒ Object
153 154 155 |
# File 'app/presenters/qa_server/monitor_status_presenter.rb', line 153 def (historical_entry) historical_entry[QaServer::MonitorStatusPresenter::HISTORICAL_FAILURE_COUNT_IDX] end |
#days_authority_passing(historical_entry) ⇒ Object
149 150 151 |
# File 'app/presenters/qa_server/monitor_status_presenter.rb', line 149 def (historical_entry) historical_entry[QaServer::MonitorStatusPresenter::HISTORICAL_PASSING_COUNT_IDX] end |
#days_authority_tested(historical_entry) ⇒ Object
157 158 159 |
# File 'app/presenters/qa_server/monitor_status_presenter.rb', line 157 def (historical_entry) (historical_entry) + (historical_entry) end |
#display_historical_datatable? ⇒ Boolean
188 189 190 |
# File 'app/presenters/qa_server/monitor_status_presenter.rb', line 188 def display_historical_datatable? QaServer.config.display_historical_datatable? end |
#display_historical_graph? ⇒ Boolean
184 185 186 |
# File 'app/presenters/qa_server/monitor_status_presenter.rb', line 184 def display_historical_graph? QaServer.config.display_historical_graph? end |
#display_history_details? ⇒ Boolean
180 181 182 |
# File 'app/presenters/qa_server/monitor_status_presenter.rb', line 180 def display_history_details? display_historical_graph? || display_historical_datatable? end |
#failing_authorities_count ⇒ Integer
Returns number of authorities with failing tests in the latest test run.
53 54 55 |
# File 'app/presenters/qa_server/monitor_status_presenter.rb', line 53 def @current_failure_data.map { |f| f[:authority_name] }.uniq.count end |
#failing_tests_count ⇒ Integer
Returns number of failing tests in the latest test run.
73 74 75 |
# File 'app/presenters/qa_server/monitor_status_presenter.rb', line 73 def failing_tests_count @current_summary.failing_scenario_count end |
#failing_tests_style ⇒ String
Returns css style class representing whether all tests passed or any failed.
78 79 80 |
# File 'app/presenters/qa_server/monitor_status_presenter.rb', line 78 def failing_tests_style failures? ? 'summary-status-bad' : 'status-good' end |
#failure_style_class(historical_entry) ⇒ Object
169 170 171 172 173 |
# File 'app/presenters/qa_server/monitor_status_presenter.rb', line 169 def failure_style_class(historical_entry) return "status-neutral" if (historical_entry) <= 0 return "status-unknown" if (historical_entry) < 0.1 "status-bad" end |
#failures ⇒ Array<Hash>
Returns A list of failures data in the latest test run, if any.
92 93 94 |
# File 'app/presenters/qa_server/monitor_status_presenter.rb', line 92 def failures @current_failure_data end |
#failures? ⇒ Boolean
Returns true if failure data exists for the latest test run; otherwise false.
97 98 99 |
# File 'app/presenters/qa_server/monitor_status_presenter.rb', line 97 def failures? failing_tests_count.positive? end |
#first_updated ⇒ String
Returns date of first recorded test run.
43 44 45 |
# File 'app/presenters/qa_server/monitor_status_presenter.rb', line 43 def first_updated QaServer::ScenarioRunRegistry.first.dt_stamp.in_time_zone("Eastern Time (US & Canada)").strftime("%m/%d/%y - %I:%M %p") end |
#historical_data_authority_name(historical_entry) ⇒ Object
145 146 147 |
# File 'app/presenters/qa_server/monitor_status_presenter.rb', line 145 def (historical_entry) historical_entry[QaServer::MonitorStatusPresenter::HISTORICAL_AUTHORITY_NAME_IDX] end |
#historical_graph ⇒ Object
115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'app/presenters/qa_server/monitor_status_presenter.rb', line 115 def historical_graph # g = Gruff::SideStackedBar.new('800x400') g = Gruff::SideStackedBar.new historical_graph_theme(g) g.title = '' historical_data = rework_historical_data_for_gruff g.labels = historical_data[0] g.data('Fail', historical_data[1]) g.data('Pass', historical_data[2]) g.write historical_graph_full_path File.join(graph_relative_path, historical_graph_filename) end |
#historical_summary ⇒ Array<Hash>
Returns historical test data to be displayed (authname, failing, passing).
105 106 107 |
# File 'app/presenters/qa_server/monitor_status_presenter.rb', line 105 def historical_summary @historical_summary_data end |
#history? ⇒ Boolean
Returns true if historical test data exists; otherwise false.
110 111 112 113 |
# File 'app/presenters/qa_server/monitor_status_presenter.rb', line 110 def history? return true if @historical_summary_data.present? false end |
#last_updated ⇒ String
Returns date of last test run.
38 39 40 |
# File 'app/presenters/qa_server/monitor_status_presenter.rb', line 38 def last_updated @current_summary.run_dt_stamp.in_time_zone("Eastern Time (US & Canada)").strftime("%m/%d/%y - %I:%M %p") end |
#passing_style_class(historical_entry) ⇒ Object
175 176 177 178 |
# File 'app/presenters/qa_server/monitor_status_presenter.rb', line 175 def passing_style_class(historical_entry) return "status-bad" if (historical_entry) <= 0 "status-good" end |
#passing_tests_count ⇒ Integer
Returns number of passing tests in the latest test run.
68 69 70 |
# File 'app/presenters/qa_server/monitor_status_presenter.rb', line 68 def passing_tests_count @current_summary.passing_scenario_count end |
#percent_authority_failing(historical_entry) ⇒ Object
161 162 163 |
# File 'app/presenters/qa_server/monitor_status_presenter.rb', line 161 def (historical_entry) (historical_entry).to_f / (historical_entry) end |
#percent_authority_failing_str(historical_entry) ⇒ Object
165 166 167 |
# File 'app/presenters/qa_server/monitor_status_presenter.rb', line 165 def (historical_entry) "#{percent_authority_failing(historical_entry) * 100}%" end |
#performance_data? ⇒ Boolean
192 193 194 |
# File 'app/presenters/qa_server/monitor_status_presenter.rb', line 192 def performance_data? @performance_data.present? end |
#performance_for_day_graph ⇒ Object
196 197 198 199 200 201 |
# File 'app/presenters/qa_server/monitor_status_presenter.rb', line 196 def performance_for_day_graph performance_graph_file(rework_performance_data_for_gruff(@performance_data[PERFORMANCE_FOR_DAY_KEY], :hour), performance_for_day_graph_full_path, performance_for_day_graph_filename, I18n.t('qa_server.monitor_status.performance.x_axis_hour')) end |
#performance_for_month_graph ⇒ Object
203 204 205 206 207 208 |
# File 'app/presenters/qa_server/monitor_status_presenter.rb', line 203 def performance_for_month_graph performance_graph_file(rework_performance_data_for_gruff(@performance_data[PERFORMANCE_FOR_MONTH_KEY], :day), performance_for_month_graph_full_path, performance_for_month_graph_filename, I18n.t('qa_server.monitor_status.performance.x_axis_day')) end |
#performance_for_year_graph ⇒ Object
210 211 212 213 214 215 |
# File 'app/presenters/qa_server/monitor_status_presenter.rb', line 210 def performance_for_year_graph performance_graph_file(rework_performance_data_for_gruff(@performance_data[PERFORMANCE_FOR_YEAR_KEY], :month), performance_for_year_graph_full_path, performance_for_year_graph_filename, I18n.t('qa_server.monitor_status.performance.x_axis_month')) end |
#status_label(status) ⇒ String
Returns the name of the css style class to use for the status cell based on the status of the scenario test.
134 135 136 137 138 139 140 141 142 143 |
# File 'app/presenters/qa_server/monitor_status_presenter.rb', line 134 def status_label(status) case status[:status] when :good QaServer::ScenarioRunHistory::GOOD_MARKER when :bad QaServer::ScenarioRunHistory::BAD_MARKER when :unknown QaServer::ScenarioRunHistory::UNKNOWN_MARKER end end |
#status_style_class(status) ⇒ String
Returns the name of the css style class to use for the status cell based on the status of the scenario test.
129 130 131 |
# File 'app/presenters/qa_server/monitor_status_presenter.rb', line 129 def status_style_class(status) "status-#{status[:status]}" end |
#tests_count ⇒ Integer
Returns number of tests in the latest test run.
63 64 65 |
# File 'app/presenters/qa_server/monitor_status_presenter.rb', line 63 def tests_count @current_summary.total_scenario_count end |