Class: QaServer::MonitorStatus::HistoryUpDownPresenter

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent:, historical_up_down_data:) ⇒ HistoryUpDownPresenter

Returns a new instance of HistoryUpDownPresenter.

Examples:

historical_up_down_data

{ 'AGROVOC' = [
    :FULLY_UP,   # 0 - today
    :MOSTLY_UP,  # 1 - yesterday
    :MOSTLY_UP,  # 2 - two days ago
    :FULLY_UP,   # 3 - three days ago
    :DOWN,       # 4 - four days ago
    ...          # etc.
  ],
  'CERL' = [ ... ]
}

Parameters:

  • parent (QaServer::MonitorStatusPresenter)

    parent presenter

  • historical_up_down_data (Hash<Array>)

    recent connection status of queries (typically last 30 days)



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

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

Instance Attribute Details

#historical_up_down_dataObject (readonly)

Returns the value of attribute historical_up_down_data.



5
6
7
# File 'app/presenters/qa_server/monitor_status/history_up_down_presenter.rb', line 5

def historical_up_down_data
  @historical_up_down_data
end

Instance Method Details

#display_historical_up_down?Boolean

Returns true if historical datatable should be visible; otherwise false.

Returns:

  • (Boolean)

    true if historical datatable should be visible; otherwise false



54
55
56
# File 'app/presenters/qa_server/monitor_status/history_up_down_presenter.rb', line 54

def display_historical_up_down?
  QaServer.config.display_historical_datatable? && @historical_up_down_data.present?
end

#historical_up_down_status_class(status, day) ⇒ String

Returns name of the css class for the status.

Parameters:

  • status (Symbol)

    :fully_up, :mostly_up, :timeouts, :barely_up, :down

  • day (Integer)

    retrieve the status for this day

Returns:

  • (String)

    name of the css class for the status



42
43
44
45
46
47
48
49
50
51
# File 'app/presenters/qa_server/monitor_status/history_up_down_presenter.rb', line 42

def historical_up_down_status_class(status, day) # rubocop:disable Metrics/CyclomaticComplexity
  case status[day]
  when :no_date then 'connection-no-date'
  when :fully_up then 'connection-fully-up'
  when :mostly_up then 'connection-mostly-up'
  when :timeouts then 'connection-timeouts'
  when :barely_up then 'connection-barely-up'
  when :down then 'connection-down'
  end
end

#up_down_endObject



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

def up_down_end
  QaServer::TimeService.pretty_date(up_down_end_dt)
end

#up_down_end_dtObject



35
36
37
# File 'app/presenters/qa_server/monitor_status/history_up_down_presenter.rb', line 35

def up_down_end_dt
  @parent.last_updated_dt
end

#up_down_startActiveSupport::TimeWithZone

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

Returns:

  • (ActiveSupport::TimeWithZone)

    date time stamp



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

def up_down_start
  QaServer::TimeService.pretty_date(up_down_end_dt - 29.days)
end