Class: QaServer::MonitorStatus::HistoryPresenter
- Inherits:
-
Object
- Object
- QaServer::MonitorStatus::HistoryPresenter
- Includes:
- GruffGraph
- Defined in:
- app/presenters/qa_server/monitor_status/history_presenter.rb
Constant Summary collapse
- HISTORICAL_AUTHORITY_NAME_IDX =
0- HISTORICAL_FAILURE_COUNT_IDX =
1- HISTORICAL_PASSING_COUNT_IDX =
2
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.
-
#initialize(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 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.
Constructor Details
#initialize(historical_summary_data:) ⇒ HistoryPresenter
Returns a new instance of HistoryPresenter.
12 13 14 |
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 12 def initialize(historical_summary_data:) @historical_summary_data = historical_summary_data end |
Instance Method Details
#days_authority_failing(historical_entry) ⇒ Object
68 69 70 |
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 68 def (historical_entry) historical_entry[HISTORICAL_FAILURE_COUNT_IDX] end |
#days_authority_passing(historical_entry) ⇒ Object
64 65 66 |
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 64 def (historical_entry) historical_entry[HISTORICAL_PASSING_COUNT_IDX] end |
#days_authority_tested(historical_entry) ⇒ Object
72 73 74 |
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 72 def (historical_entry) (historical_entry) + (historical_entry) end |
#display_historical_datatable? ⇒ Boolean
103 104 105 |
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 103 def display_historical_datatable? QaServer.config.display_historical_datatable? end |
#display_historical_graph? ⇒ Boolean
99 100 101 |
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 99 def display_historical_graph? QaServer.config.display_historical_graph? end |
#display_history_details? ⇒ Boolean
95 96 97 |
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 95 def display_history_details? display_historical_graph? || display_historical_datatable? end |
#failure_style_class(historical_entry) ⇒ Object
84 85 86 87 88 |
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 84 def failure_style_class(historical_entry) return "status-neutral" if (historical_entry) <= 0 return "status-unknown" if (historical_entry) < 0.1 "status-bad" end |
#historical_data_authority_name(historical_entry) ⇒ Object
60 61 62 |
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 60 def (historical_entry) historical_entry[HISTORICAL_AUTHORITY_NAME_IDX] end |
#historical_graph ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 30 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).
20 21 22 |
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 20 def historical_summary @historical_summary_data end |
#history? ⇒ Boolean
Returns true if historical test data exists; otherwise false.
25 26 27 28 |
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 25 def history? return true if @historical_summary_data.present? false end |
#passing_style_class(historical_entry) ⇒ Object
90 91 92 93 |
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 90 def passing_style_class(historical_entry) return "status-bad" if (historical_entry) <= 0 "status-good" end |
#percent_authority_failing(historical_entry) ⇒ Object
76 77 78 |
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 76 def (historical_entry) (historical_entry).to_f / (historical_entry) end |
#percent_authority_failing_str(historical_entry) ⇒ Object
80 81 82 |
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 80 def (historical_entry) "#{(historical_entry) * 100}%" 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.
49 50 51 52 53 54 55 56 57 58 |
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 49 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.
44 45 46 |
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 44 def status_style_class(status) "status-#{status[:status]}" end |