Sha256: 72c77579eb84f2b0b8363993a7de62f1d0b939115f5d4cf8df26009eba7fa283

Contents?: true

Size: 499 Bytes

Versions: 70

Compression:

Stored size: 499 Bytes

Contents

module ForemanRhCloud
  class InsightsStatusCleaner
    def clean(host_search)
      host_ids = Host.search_for(host_search).pluck(:id)

      # delete all insights status records for the hosts
      deleted_count = InsightsClientReportStatus.where(host_id: host_ids).delete_all

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

      deleted_count
    end
  end
end

Version data entries

70 entries across 70 versions & 1 rubygems

Version Path
foreman_rh_cloud-11.1.0 app/services/foreman_rh_cloud/insights_status_cleaner.rb
foreman_rh_cloud-10.0.3 app/services/foreman_rh_cloud/insights_status_cleaner.rb
foreman_rh_cloud-11.0.3 app/services/foreman_rh_cloud/insights_status_cleaner.rb
foreman_rh_cloud-9.0.59 app/services/foreman_rh_cloud/insights_status_cleaner.rb
foreman_rh_cloud-11.0.2 app/services/foreman_rh_cloud/insights_status_cleaner.rb
foreman_rh_cloud-11.0.1 app/services/foreman_rh_cloud/insights_status_cleaner.rb
foreman_rh_cloud-11.0.0 app/services/foreman_rh_cloud/insights_status_cleaner.rb
foreman_rh_cloud-9.0.58 app/services/foreman_rh_cloud/insights_status_cleaner.rb
foreman_rh_cloud-10.0.2 app/services/foreman_rh_cloud/insights_status_cleaner.rb
foreman_rh_cloud-9.0.57 app/services/foreman_rh_cloud/insights_status_cleaner.rb
foreman_rh_cloud-10.0.1 app/services/foreman_rh_cloud/insights_status_cleaner.rb
foreman_rh_cloud-9.0.56 app/services/foreman_rh_cloud/insights_status_cleaner.rb
foreman_rh_cloud-9.0.55 app/services/foreman_rh_cloud/insights_status_cleaner.rb
foreman_rh_cloud-9.0.54 app/services/foreman_rh_cloud/insights_status_cleaner.rb
foreman_rh_cloud-9.0.53 app/services/foreman_rh_cloud/insights_status_cleaner.rb
foreman_rh_cloud-9.0.52 app/services/foreman_rh_cloud/insights_status_cleaner.rb
foreman_rh_cloud-8.0.52 app/services/foreman_rh_cloud/insights_status_cleaner.rb
foreman_rh_cloud-9.0.51 app/services/foreman_rh_cloud/insights_status_cleaner.rb
foreman_rh_cloud-8.0.51 app/services/foreman_rh_cloud/insights_status_cleaner.rb
foreman_rh_cloud-7.0.48 app/services/foreman_rh_cloud/insights_status_cleaner.rb