Class: InsightsCloud::Async::InsightsClientStatusAging

Inherits:
Actions::EntryAction
  • Object
show all
Includes:
Actions::RecurringAction
Defined in:
lib/insights_cloud/async/insights_client_status_aging.rb

Instance Method Summary collapse

Instance Method Details

#loggerObject



18
19
20
# File 'lib/insights_cloud/async/insights_client_status_aging.rb', line 18

def logger
  action_logger
end

#rescue_strategy_for_selfObject



22
23
24
# File 'lib/insights_cloud/async/insights_client_status_aging.rb', line 22

def rescue_strategy_for_self
  Dynflow::Action::Rescue::Fail
end

#runObject



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/insights_cloud/async/insights_client_status_aging.rb', line 6

def run
  host_ids = InsightsClientReportStatus.stale.reporting.pluck(:host_id)

  # update all stale records
  InsightsClientReportStatus.where(host_id: host_ids).update_all(status: InsightsClientReportStatus::NO_REPORT)

  # refresh global status
  Host.where(id: host_ids).preload(:host_statuses).find_in_batches do |hosts|
    hosts.each { |host| host.refresh_global_status! }
  end
end