Class: InsightsClientReportStatus

Inherits:
HostStatus::Status
  • Object
show all
Defined in:
app/models/insights_client_report_status.rb

Constant Summary collapse

REPORT_INTERVAL =
48.hours
REPORTING =
0
NO_REPORT =
1
USER_OMITTED =
2

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.status_nameObject



11
12
13
# File 'app/models/insights_client_report_status.rb', line 11

def self.status_name
  N_('Insights')
end

Instance Method Details

#relevant?(_options = {}) ⇒ Boolean

prevent creation of the status on global refresh, but show it if the record already exists

Returns:

  • (Boolean)


45
46
47
# File 'app/models/insights_client_report_status.rb', line 45

def relevant?(_options = {})
  persisted?
end

#to_global(_options = {}) ⇒ Object



26
27
28
29
30
31
32
33
34
35
# File 'app/models/insights_client_report_status.rb', line 26

def to_global(_options = {})
  case status
  when REPORTING
    ::HostStatus::Global::OK
  when NO_REPORT
    ::HostStatus::Global::ERROR
  when USER_OMITTED
    ::HostStatus::Global::OK
  end
end

#to_label(_options = {}) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'app/models/insights_client_report_status.rb', line 15

def to_label(_options = {})
  case status
  when REPORTING
    N_('Reporting')
  when NO_REPORT
    N_('Not reporting')
  when USER_OMITTED
    N_('Not reporting because host_registration_insights parameter value is false')
  end
end

#to_statusObject



37
38
39
40
41
42
# File 'app/models/insights_client_report_status.rb', line 37

def to_status
  excluded_by_host_param =
    ::Foreman::Cast.to_bool(host.host_param('host_registration_insights')) == false
  return USER_OMITTED if excluded_by_host_param
  in_interval? ? REPORTING : NO_REPORT
end