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
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
67 68 69 |
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 67 def (historical_entry) historical_entry[HISTORICAL_FAILURE_COUNT_IDX] end |
#days_authority_passing(historical_entry) ⇒ Object
63 64 65 |
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 63 def (historical_entry) historical_entry[HISTORICAL_PASSING_COUNT_IDX] end |
#days_authority_tested(historical_entry) ⇒ Object
71 72 73 |
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 71 def (historical_entry) (historical_entry) + (historical_entry) end |
#display_historical_datatable? ⇒ Boolean
102 103 104 |
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 102 def display_historical_datatable? QaServer.config.display_historical_datatable? end |
#display_historical_graph? ⇒ Boolean
98 99 100 |
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 98 def display_historical_graph? QaServer.config.display_historical_graph? end |
#display_history_details? ⇒ Boolean
94 95 96 |
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 94 def display_history_details? display_historical_graph? || display_historical_datatable? end |
#failure_style_class(historical_entry) ⇒ Object
83 84 85 86 87 |
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 83 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
59 60 61 |
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 59 def (historical_entry) historical_entry[HISTORICAL_AUTHORITY_NAME_IDX] end |
#historical_graph ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 |
# 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) 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
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
89 90 91 92 |
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 89 def passing_style_class(historical_entry) return "status-bad" if (historical_entry) <= 0 "status-good" end |
#percent_authority_failing(historical_entry) ⇒ Object
75 76 77 |
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 75 def (historical_entry) (historical_entry).to_f / (historical_entry) end |
#percent_authority_failing_str(historical_entry) ⇒ Object
79 80 81 |
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 79 def (historical_entry) "#{percent_authority_failing(historical_entry) * 100}%" end |
#status_label(status) ⇒ String
48 49 50 51 52 53 54 55 56 57 |
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 48 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
43 44 45 |
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 43 def status_style_class(status) "status-#{status[:status]}" end |