Class: QaServer::MonitorStatus::HistoryPresenter

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

Instance Method Summary collapse

Constructor Details

#initialize(parent:, historical_summary_data:) ⇒ HistoryPresenter

Returns a new instance of HistoryPresenter.

Parameters:

  • parent (QaServer::MonitorStatusPresenter)

    parent presenter

  • historical_summary_data (Array<Hash>)

    summary of past failuring runs per authority to drive chart



7
8
9
10
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 7

def initialize(parent:, historical_summary_data:)
  @parent = parent
  @historical_summary_data = historical_summary_data
end

Instance Method Details

#days_authority_failing(historical_entry) ⇒ Object



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

def days_authority_failing(historical_entry)
  historical_entry[1][:bad]
end

#days_authority_passing(historical_entry) ⇒ Object



76
77
78
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 76

def days_authority_passing(historical_entry)
  historical_entry[1][:good]
end

#days_authority_tested(historical_entry) ⇒ Object



84
85
86
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 84

def days_authority_tested(historical_entry)
  days_authority_passing(historical_entry) + days_authority_failing(historical_entry)
end

#display_historical_datatable?Boolean

Returns:

  • (Boolean)


113
114
115
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 113

def display_historical_datatable?
  QaServer.config.display_historical_datatable?
end

#display_historical_graph?Boolean

Returns:

  • (Boolean)


109
110
111
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 109

def display_historical_graph?
  QaServer.config.display_historical_graph? && QaServer::HistoryGraphingService.history_graph_image_exists?
end

#display_history_details?Boolean

Returns:

  • (Boolean)


105
106
107
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 105

def display_history_details?
  display_historical_graph? || display_historical_datatable?
end

#failure_style_class(historical_entry) ⇒ Object



96
97
98
99
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 96

def failure_style_class(historical_entry)
  return "status-neutral" if days_authority_failing(historical_entry) <= 0
  percent_authority_failing(historical_entry) < 0.10 ? "status-unknown" : "status-bad"
end

#historical_data_authority_name(historical_entry) ⇒ Object



72
73
74
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 72

def historical_data_authority_name(historical_entry)
  historical_entry[0]
end

#historical_graphObject



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

def historical_graph
  QaServer::HistoryGraphingService.history_graph_image_path
end

#historical_summaryArray<Hash>

Returns historical test data to be displayed (authname, failing, passing).

Examples:

[ [ 'agrovoc', 0, 24 ],
  [ 'geonames_ld4l_cache', 2, 22 ] ... ]

Returns:

  • (Array<Hash>)

    historical test data to be displayed (authname, failing, passing)



16
17
18
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 16

def historical_summary
  @historical_summary_data
end

#history?Boolean

Returns true if historical test data exists; otherwise false.

Returns:

  • (Boolean)

    true if historical test data exists; otherwise false



25
26
27
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 25

def history?
  @historical_summary_data.present?
end

#history_endString

Return the last date of data represented in the history graph and data table

Returns:

  • (String)

    string version of date formatted with just date (e.g. “02/01/2020”)



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

def history_end
  QaServer::TimeService.pretty_date(history_end_dt)
end

#history_end_dtActiveSupport::TimeWithZone

Return the last date of data represented in the history graph and data table

Returns:

  • (ActiveSupport::TimeWithZone)

    date time stamp



45
46
47
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 45

def history_end_dt
  @parent.last_updated_dt
end

#history_startString

Return the first date of data represented in the history graph and data table

Returns:

  • (String)

    string version of date formatted with just date (e.g. “02/01/2020”)



31
32
33
34
35
36
37
38
39
40
41
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 31

def history_start
  start_dt = case QaServer.config.historical_datatable_default_time_period
             when :month
               history_end_dt - 1.month
             when :year
               history_end_dt - 1.year
             else
               @parent.first_updated_dt
             end
  QaServer::TimeService.pretty_date(start_dt)
end

#passing_style_class(historical_entry) ⇒ Object



101
102
103
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 101

def passing_style_class(historical_entry)
  days_authority_passing(historical_entry) <= 0 ? "status-bad" : "status-good"
end

#percent_authority_failing(historical_entry) ⇒ Object



88
89
90
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 88

def percent_authority_failing(historical_entry)
  days_authority_failing(historical_entry).to_f / days_authority_tested(historical_entry)
end

#percent_authority_failing_str(historical_entry) ⇒ Object



92
93
94
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 92

def percent_authority_failing_str(historical_entry)
  ActiveSupport::NumberHelper.number_to_percentage(percent_authority_failing(historical_entry) * 100, precision: 1)
end

#status_label(status) ⇒ String

Returns the marker to use for the status cell based on the status of the scenario test.

Returns:

  • (String)

    the marker to use for the status cell based on the status of the scenario test



61
62
63
64
65
66
67
68
69
70
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 61

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.

Returns:

  • (String)

    the name of the css style class to use for the status cell based on the status of the scenario test.



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

def status_style_class(status)
  "status-#{status[:status]}"
end