Class: QaServer::MonitorStatus::CurrentStatusPresenter

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

Instance Method Summary collapse

Constructor Details

#initialize(parent:, current_summary:, current_failure_data:) ⇒ CurrentStatusPresenter

Returns a new instance of CurrentStatusPresenter.

Parameters:



8
9
10
11
12
# File 'app/presenters/qa_server/monitor_status/current_status_presenter.rb', line 8

def initialize(parent:, current_summary:, current_failure_data:)
  @parent = parent
  @current_summary = current_summary
  @current_failure_data = current_failure_data
end

Instance Method Details

#authorities_countInteger

Returns number of loaded authorities.

Returns:

  • (Integer)

    number of loaded authorities



36
37
38
# File 'app/presenters/qa_server/monitor_status/current_status_presenter.rb', line 36

def authorities_count
  @current_summary ? @current_summary.authority_count : "N/A"
end

#authorities_count_styleString

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



46
47
48
# File 'app/presenters/qa_server/monitor_status/current_status_presenter.rb', line 46

def authorities_count_style
  failures? ? 'status-bad' : 'status-good'
end

#failing_authorities_countInteger

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



41
42
43
# File 'app/presenters/qa_server/monitor_status/current_status_presenter.rb', line 41

def failing_authorities_count
  @current_failure_data ? @current_failure_data.map { |f| f[:authority_name] }.uniq.count : "N/A"
end

#failing_tests_countInteger

Returns number of failing tests in the latest test run.

Returns:

  • (Integer)

    number of failing tests in the latest test run



61
62
63
# File 'app/presenters/qa_server/monitor_status/current_status_presenter.rb', line 61

def failing_tests_count
  @current_summary ? @current_summary.failing_scenario_count : 0
end

#failing_tests_styleString

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



66
67
68
# File 'app/presenters/qa_server/monitor_status/current_status_presenter.rb', line 66

def failing_tests_style
  failures? ? 'summary-status-bad' : 'status-good'
end

#failuresArray<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



80
81
82
# File 'app/presenters/qa_server/monitor_status/current_status_presenter.rb', line 80

def failures
  @current_failure_data ? @current_failure_data : []
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



85
86
87
# File 'app/presenters/qa_server/monitor_status/current_status_presenter.rb', line 85

def failures?
  failing_tests_count.positive? && !failures.nil?
end

#first_updatedString

Returns date with time of first recorded test run.

Returns:

  • (String)

    date with time of first recorded test run



31
32
33
# File 'app/presenters/qa_server/monitor_status/current_status_presenter.rb', line 31

def first_updated
  QaServer::TimeService.pretty_time(first_updated_dt)
end

#first_updated_dtActiveSupport::TimeWithZone

Returns date time stamp of first recorded test run.

Returns:

  • (ActiveSupport::TimeWithZone)

    date time stamp of first recorded test run



26
27
28
# File 'app/presenters/qa_server/monitor_status/current_status_presenter.rb', line 26

def first_updated_dt
  QaServer::ScenarioRunRegistry.first_run_dt
end

#last_updatedString

Returns date with time of last test run.

Returns:

  • (String)

    date with time of last test run



20
21
22
23
# File 'app/presenters/qa_server/monitor_status/current_status_presenter.rb', line 20

def last_updated
  return I18n.t('qa_server.monitor_status.summary.no_data') if @current_summary.blank?
  I18n.t('qa_server.monitor_status.summary.last_updated', date: QaServer::TimeService.pretty_time(last_updated_dt))
end

#last_updated_dtActiveSupport::TimeWithZone

Returns date time stamp of last test run.

Returns:

  • (ActiveSupport::TimeWithZone)

    date time stamp of last test run



15
16
17
# File 'app/presenters/qa_server/monitor_status/current_status_presenter.rb', line 15

def last_updated_dt
  @current_summary ? @current_summary.run_dt_stamp : QaServer::TimeService.current_time
end

#passing_tests_countInteger

Returns number of passing tests in the latest test run.

Returns:

  • (Integer)

    number of passing tests in the latest test run



56
57
58
# File 'app/presenters/qa_server/monitor_status/current_status_presenter.rb', line 56

def passing_tests_count
  @current_summary ? @current_summary.passing_scenario_count : 0
end

#tests_countInteger

Returns number of tests in the latest test run.

Returns:

  • (Integer)

    number of tests in the latest test run



51
52
53
# File 'app/presenters/qa_server/monitor_status/current_status_presenter.rb', line 51

def tests_count
  @current_summary ? @current_summary.total_scenario_count : 0
end