Class: QaServer::MonitorStatus::HistoryPresenter

Inherits:
Object
  • Object
show all
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

Constructor Details

#initialize(historical_summary_data:) ⇒ HistoryPresenter

Returns a new instance of HistoryPresenter.

Parameters:

  • historical_summary_data (Array<Hash>)

    summary of past failuring runs per authority to drive chart



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 days_authority_failing(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 days_authority_passing(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 days_authority_tested(historical_entry)
  days_authority_passing(historical_entry) + days_authority_failing(historical_entry)
end

#display_historical_datatable?Boolean

Returns:

  • (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

Returns:

  • (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

Returns:

  • (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 days_authority_failing(historical_entry) <= 0
  return "status-unknown" if percent_authority_failing(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_data_authority_name(historical_entry)
  historical_entry[HISTORICAL_AUTHORITY_NAME_IDX]
end

#historical_graphObject



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_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)



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

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
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 days_authority_passing(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 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



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

def percent_authority_failing_str(historical_entry)
  "#{percent_authority_failing(historical_entry) * 100}%"
end

#status_label(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.



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

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.



43
44
45
# File 'app/presenters/qa_server/monitor_status/history_presenter.rb', line 43

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