Class: QaServer::MonitorStatusPresenter

Inherits:
Object
  • Object
show all
Defined in:
app/presenters/qa_server/monitor_status_presenter.rb

Instance Method Summary collapse

Constructor Details

#initialize(authority_count:, authority_status:, current_data:, historical_data:) ⇒ MonitorStatusPresenter

Returns a new instance of MonitorStatusPresenter.

Parameters:

  • authority_count (Integer) —

    number of loaded authorities

  • authority_status (AuthorityStatus) —

    summary status of the latest run of test scenarios

  • current_data (Array<Hash>) —

    current set of failures for the latest test run, if any

  • historical_data (Array<Hash>) —

    data for past failures



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_count
  @authority_status = authority_status
  @current_failures = current_data
  @history = historical_data
end

Instance Method Details

#authorities_count ⇒ Integer

Returns number of loaded authorities.

Returns:

  • (Integer) —

    number of loaded authorities



27
28
29
# File 'app/presenters/qa_server/monitor_status_presenter.rb', line 27

def authorities_count
  @authority_count
end

#authorities_count_style ⇒ String

Returns css style class representing whether all tests passed or any failed.

Returns:

  • (String) —

    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 authorities_count_style
  failures? ? 'status-bad' : 'status-good'
end

#failing_authorities_count ⇒ Integer

Returns number of authorities with failing tests in the latest test run.

Returns:

  • (Integer) —

    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 failing_authorities_count
  @current_failures.map { |f| f[:authority_name] }.uniq.count
end

#failing_tests_count ⇒ Integer

Returns number of failing tests in the latest test run.

Returns:

  • (Integer) —

    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.

Returns:

  • (String) —

    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.

Examples:

[ { status: :FAIL,
    status_label: 'X',
    authority_name: 'LOCNAMES_LD4L_CACHE',
    subauthority_name: 'person',
    service: 'ld4l_cache',
    action: 'search',
    url: '/qa/search/linked_data/locnames_ld4l_cache/person?q=mark twain&maxRecords=4',
    err_message: 'Exception: Something went wrong.' }, ... ]

Returns:

  • (Array<Hash>) —

    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.

Returns:

  • (Boolean) —

    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.

Returns:

  • (String) —

    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.

Examples:

[ { days_failing: 1, authority_name: 'AGROVOC_DIRECT' },
  { days_failing: 3, authority_name: 'AGROVOC_LD4L_CACHE' },
  { days_failing: 0, authority_name: 'LOCNAMES_LD4L_CACHE' } ]

Returns:

  • (Array<Hash>) —

    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.

Returns:

  • (Boolean) —

    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.

Returns:

  • (String) —

    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.

Returns:

  • (Integer) —

    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.

Returns:

  • (Integer) —

    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