Class: QaServer::MonitorStatusPresenter
- Inherits:
-
Object
- Object
- QaServer::MonitorStatusPresenter
- Defined in:
- app/presenters/qa_server/monitor_status_presenter.rb
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.
-
#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.
-
#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.
-
#history ⇒ Array<Hash>
Historical test data to be displayed.
-
#history? ⇒ Boolean
True if historical test data exists; otherwise false.
-
#initialize(authority_count:, authority_status:, current_data:, historical_data:) ⇒ MonitorStatusPresenter
constructor
A new instance of MonitorStatusPresenter.
-
#last_updated ⇒ String
Date of last test run.
-
#passing_tests_count ⇒ Integer
Number of passing tests in the latest test run.
-
#tests_count ⇒ Integer
Number of tests in the latest test run.
Constructor Details
#initialize(authority_count:, authority_status:, current_data:, historical_data:) ⇒ MonitorStatusPresenter
Returns a new instance of MonitorStatusPresenter.
9 10 11 12 13 14 |
# File 'app/presenters/qa_server/monitor_status_presenter.rb', line 9 def initialize(authority_count:, authority_status:, current_data:, historical_data:) @authority_count = @authority_status = @current_failures = current_data @history = historical_data end |
Instance Method Details
#authorities_count ⇒ Integer
Returns number of loaded authorities.
27 28 29 |
# File 'app/presenters/qa_server/monitor_status_presenter.rb', line 27 def @authority_count end |
#authorities_count_style ⇒ String
Returns css style class representing whether all tests passed or any failed.
37 38 39 |
# File 'app/presenters/qa_server/monitor_status_presenter.rb', line 37 def failures? ? 'status-bad' : 'status-good' end |
#failing_authorities_count ⇒ Integer
Returns number of authorities with failing tests in the latest test run.
32 33 34 |
# File 'app/presenters/qa_server/monitor_status_presenter.rb', line 32 def @current_failures.map { |f| f[:authority_name] }.uniq.count end |
#failing_tests_count ⇒ Integer
Returns number of failing tests in the latest test run.
52 53 54 |
# File 'app/presenters/qa_server/monitor_status_presenter.rb', line 52 def failing_tests_count @current_failures.count end |
#failing_tests_style ⇒ String
Returns css style class representing whether all tests passed or any failed.
57 58 59 |
# File 'app/presenters/qa_server/monitor_status_presenter.rb', line 57 def failing_tests_style failures? ? 'status-bad' : 'status-good' end |
#failures ⇒ Array<Hash>
Returns A list of failures data in the latest test run, if any.
71 72 73 |
# File 'app/presenters/qa_server/monitor_status_presenter.rb', line 71 def failures @current_failures end |
#failures? ⇒ Boolean
Returns true if failure data exists for the latest test run; otherwise false.
76 77 78 |
# File 'app/presenters/qa_server/monitor_status_presenter.rb', line 76 def failures? failing_tests_count.positive? end |
#first_updated ⇒ String
Returns date of first recorded test run.
22 23 24 |
# File 'app/presenters/qa_server/monitor_status_presenter.rb', line 22 def first_updated AuthorityStatus.first.dt_stamp.in_time_zone("Eastern Time (US & Canada)").strftime("%m/%d/%y - %I:%M %p") end |
#history ⇒ Array<Hash>
Returns historical test data to be displayed.
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'app/presenters/qa_server/monitor_status_presenter.rb', line 85 def history # TODO: STUBED -- need to include history of past failures -- Question: How much data to save? # Want to answer questions like... # * # of failing days out of # of days run # * # type of failures... can't load authority vs. exception vs. no data returned # * for a given authority, did all tests fail or just a few? # * are tests failing for a particular subauthority? # * are tests failing for a particular type (search vs. term) history = [] entry = { days_failing: 3, authority_name: "FOO", subauthority_name: "bar", service: 'test', action: 'search' } history << entry end |
#history? ⇒ Boolean
Returns true if historical test data exists; otherwise false.
103 104 105 106 |
# File 'app/presenters/qa_server/monitor_status_presenter.rb', line 103 def history? # TODO: STUBED -- need check for history data false end |
#last_updated ⇒ String
Returns date of last test run.
17 18 19 |
# File 'app/presenters/qa_server/monitor_status_presenter.rb', line 17 def last_updated @authority_status.dt_stamp.in_time_zone("Eastern Time (US & Canada)").strftime("%m/%d/%y - %I:%M %p") end |
#passing_tests_count ⇒ Integer
Returns number of passing tests in the latest test run.
47 48 49 |
# File 'app/presenters/qa_server/monitor_status_presenter.rb', line 47 def passing_tests_count tests_count - failing_tests_count end |
#tests_count ⇒ Integer
Returns number of tests in the latest test run.
42 43 44 |
# File 'app/presenters/qa_server/monitor_status_presenter.rb', line 42 def tests_count @authority_status.test_count end |