Class: QaServer::MonitorStatus::HistoryPresenter
- Inherits:
-
Object
- Object
- QaServer::MonitorStatus::HistoryPresenter
- Defined in:
- app/presenters/qa_server/monitor_status/history_presenter.rb
Constant Summary collapse
- CAUTION_THRESHOLD =
0.05
- WARNING_THRESHOLD =
0.1
Instance Method Summary collapse
-
#days_authority_failing(historical_entry) ⇒ Integer
Number of days with failing tests (e.g. 51).
-
#days_authority_passing(historical_entry) ⇒ Integer
Number of days with passing tests (e.g. 949).
-
#days_authority_tested(historical_entry) ⇒ Integer
Number of days tested (e.g. 1000).
-
#display_historical_datatable? ⇒ Boolean
True if historical datatable should be visible; otherwise false.
-
#display_historical_graph? ⇒ Boolean
True if historical graph should be visible; otherwise false.
-
#display_history_details? ⇒ Boolean
True if historical section should be visible; otherwise false.
-
#failure_style_class(historical_entry) ⇒ String
Css class for background in Days Failing and Percent Failing columns (e.g. ‘status-neutral’, ‘status-unknown’, ‘status-bad’).
-
#historical_data_authority_name(historical_entry) ⇒ String
Name of the authority (e.g. ‘AUTH_NAME’).
- #historical_graph ⇒ Object
-
#historical_summary ⇒ Array<Hash>
{ “AGROVOC_DIRECT”=>:bad=>0, “AGROVOC_LD4L_CACHE”=>:bad=>0 }.
-
#history? ⇒ Boolean
True if historical test data exists; otherwise false.
-
#history_end ⇒ String
Return the last date of data represented in the history graph and data table.
-
#history_end_dt ⇒ ActiveSupport::TimeWithZone
Return the last date of data represented in the history graph and data table.
-
#history_start ⇒ String
Return the first date of data represented in the history graph and data table.
-
#initialize(parent:, historical_summary_data:) ⇒ HistoryPresenter
constructor
{ “AGROVOC_DIRECT”=>:bad=>0, “AGROVOC_LD4L_CACHE”=>:bad=>0 }.
-
#passing_style_class(historical_entry) ⇒ String
Css class for background in Days Passing column (e.g. ‘status-good’, ‘status-bad’).
-
#percent_authority_failing(historical_entry) ⇒ Float
Percent of failing to passing tests (e.g. 0.05374 ).
-
#percent_authority_failing_str(historical_entry) ⇒ String
Percent of failing to passing tests (e.g. ‘5.4%’).
-
#status_label(status) ⇒ String
The marker 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.
Constructor Details
#initialize(parent:, historical_summary_data:) ⇒ HistoryPresenter
"AGROVOC_DIRECT"=>{:good=>4, :bad=>0,
"AGROVOC_LD4L_CACHE"=>:bad=>0
}
15 16 17 18 |
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 15 def initialize(parent:, historical_summary_data:) @parent = parent @historical_summary_data = historical_summary_data end |
Instance Method Details
#days_authority_failing(historical_entry) ⇒ Integer
Returns number of days with failing tests (e.g. 51).
102 103 104 |
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 102 def (historical_entry) historical_entry[1][:bad] end |
#days_authority_passing(historical_entry) ⇒ Integer
Returns number of days with passing tests (e.g. 949).
94 95 96 |
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 94 def (historical_entry) historical_entry[1][:good] end |
#days_authority_tested(historical_entry) ⇒ Integer
Returns number of days tested (e.g. 1000).
110 111 112 |
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 110 def (historical_entry) (historical_entry) + (historical_entry) end |
#display_historical_datatable? ⇒ Boolean
Returns true if historical datatable should be visible; otherwise false.
164 165 166 |
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 164 def display_historical_datatable? QaServer.config.display_historical_datatable? end |
#display_historical_graph? ⇒ Boolean
Returns true if historical graph should be visible; otherwise false.
159 160 161 |
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 159 def display_historical_graph? QaServer.config.display_historical_graph? && QaServer::HistoryGraphingService.history_graph_image_exists? end |
#display_history_details? ⇒ Boolean
Returns true if historical section should be visible; otherwise false.
154 155 156 |
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 154 def display_history_details? display_historical_graph? || display_historical_datatable? end |
#failure_style_class(historical_entry) ⇒ String
Returns css class for background in Days Failing and Percent Failing columns (e.g. ‘status-neutral’, ‘status-unknown’, ‘status-bad’).
134 135 136 137 138 139 140 141 142 143 |
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 134 def failure_style_class(historical_entry) case (historical_entry) when 0.0...CAUTION_THRESHOLD "status-neutral" when CAUTION_THRESHOLD...WARNING_THRESHOLD "status-unknown" else "status-bad" end end |
#historical_data_authority_name(historical_entry) ⇒ String
Returns name of the authority (e.g. ‘AUTH_NAME’).
86 87 88 |
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 86 def (historical_entry) historical_entry[0] end |
#historical_graph ⇒ Object
30 31 32 |
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 30 def historical_graph QaServer::HistoryGraphingService.history_graph_image_path end |
#historical_summary ⇒ Array<Hash>
"AGROVOC_DIRECT"=>{:good=>4, :bad=>0,
"AGROVOC_LD4L_CACHE"=>:bad=>0
}
26 27 28 |
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 26 def historical_summary @historical_summary_data end |
#history? ⇒ Boolean
Returns true if historical test data exists; otherwise false.
35 36 37 |
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 35 def history? @historical_summary_data.present? end |
#history_end ⇒ String
Return the last date of data represented in the history graph and data table
61 62 63 |
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 61 def history_end QaServer::TimeService.pretty_date(history_end_dt) end |
#history_end_dt ⇒ ActiveSupport::TimeWithZone
Return the last date of data represented in the history graph and data table
55 56 57 |
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 55 def history_end_dt @parent.last_updated_dt end |
#history_start ⇒ String
Return the first date of data represented in the history graph and data table
41 42 43 44 45 46 47 48 49 50 51 |
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 41 def history_start start_dt = case QaServer.config.historical_datatable_default_time_period when :month history_end_dt - 1.month when :year history_end_dt - 1.year else @parent.first_updated_dt end QaServer::TimeService.pretty_date(start_dt) end |
#passing_style_class(historical_entry) ⇒ String
Returns css class for background in Days Passing column (e.g. ‘status-good’, ‘status-bad’).
149 150 151 |
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 149 def passing_style_class(historical_entry) (historical_entry) <= 0 ? "status-bad" : "status-good" end |
#percent_authority_failing(historical_entry) ⇒ Float
Returns percent of failing to passing tests (e.g. 0.05374 ).
118 119 120 |
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 118 def (historical_entry) (historical_entry).to_f / (historical_entry) end |
#percent_authority_failing_str(historical_entry) ⇒ String
Returns percent of failing to passing tests (e.g. ‘5.4%’).
126 127 128 |
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 126 def (historical_entry) ActiveSupport::NumberHelper.number_to_percentage((historical_entry) * 100, precision: 1) end |
#status_label(status) ⇒ String
Returns the marker to use for the status cell based on the status of the scenario test.
71 72 73 74 75 76 77 78 79 80 |
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 71 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.
66 67 68 |
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 66 def status_style_class(status) "status-#{status[:status]}" end |