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) ⇒ 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
- #failure_style_class(historical_entry) ⇒ Object
- #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.
-
#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
A new instance of HistoryPresenter.
- #passing_style_class(historical_entry) ⇒ Object
- #percent_authority_failing(historical_entry) ⇒ Object
- #percent_authority_failing_str(historical_entry) ⇒ Object
-
#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
Returns a new instance of HistoryPresenter.
10 11 12 13 |
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 10 def initialize(parent:, historical_summary_data:) @parent = parent @historical_summary_data = historical_summary_data end |
Instance Method Details
#days_authority_failing(historical_entry) ⇒ Object
83 84 85 |
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 83 def (historical_entry) historical_entry[1][:bad] end |
#days_authority_passing(historical_entry) ⇒ Object
79 80 81 |
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 79 def (historical_entry) historical_entry[1][:good] end |
#days_authority_tested(historical_entry) ⇒ Object
87 88 89 |
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 87 def (historical_entry) (historical_entry) + (historical_entry) end |
#display_historical_datatable? ⇒ Boolean
116 117 118 |
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 116 def display_historical_datatable? QaServer.config.display_historical_datatable? end |
#display_historical_graph? ⇒ Boolean
112 113 114 |
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 112 def display_historical_graph? QaServer.config.display_historical_graph? && QaServer::HistoryGraphingService.history_graph_image_exists? end |
#display_history_details? ⇒ Boolean
108 109 110 |
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 108 def display_history_details? display_historical_graph? || display_historical_datatable? end |
#failure_style_class(historical_entry) ⇒ Object
99 100 101 102 |
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 99 def failure_style_class(historical_entry) return "status-neutral" if (historical_entry) <= CAUTION_THRESHOLD (historical_entry) < WARNING_THRESHOLD ? "status-unknown" : "status-bad" end |
#historical_data_authority_name(historical_entry) ⇒ Object
75 76 77 |
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 75 def (historical_entry) historical_entry[0] end |
#historical_graph ⇒ Object
23 24 25 |
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 23 def historical_graph QaServer::HistoryGraphingService.history_graph_image_path end |
#historical_summary ⇒ Array<Hash>
Returns historical test data to be displayed (authname, failing, passing).
19 20 21 |
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 19 def historical_summary @historical_summary_data end |
#history? ⇒ Boolean
Returns true if historical test data exists; otherwise false.
28 29 30 |
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 28 def history? @historical_summary_data.present? end |
#history_end ⇒ String
Return the last date of data represented in the history graph and data table
54 55 56 |
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 54 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
48 49 50 |
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 48 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
34 35 36 37 38 39 40 41 42 43 44 |
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 34 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) ⇒ Object
104 105 106 |
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 104 def passing_style_class(historical_entry) (historical_entry) <= 0 ? "status-bad" : "status-good" end |
#percent_authority_failing(historical_entry) ⇒ Object
91 92 93 |
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 91 def (historical_entry) (historical_entry).to_f / (historical_entry) end |
#percent_authority_failing_str(historical_entry) ⇒ Object
95 96 97 |
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 95 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.
64 65 66 67 68 69 70 71 72 73 |
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 64 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.
59 60 61 |
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 59 def status_style_class(status) "status-#{status[:status]}" end |