Sha256: 606572d53a45aaf9d5547b4361b3b3610b4266e02a10d7b3131166b97515e385

Contents?: true

Size: 1.09 KB

Versions: 27

Compression:

Stored size: 1.09 KB

Contents

module ForemanInventoryUpload
  module Async
    class GenerateAllReportsJob < ::ApplicationJob
      def perform
        unless Setting[:allow_auto_inventory_upload]
          logger.debug(
            'The scheduled process is disabled due to the "allow_auto_inventory_upload"
            setting being set to false.'
          )
          return
        end

        organizations = Organization.unscoped.all

        organizations.map do |organization|
          total_hosts = ForemanInventoryUpload::Generators::Queries.for_org(organization.id, use_batches: false).count

          if total_hosts <= ForemanInventoryUpload.max_org_size
            GenerateReportJob.perform_later(ForemanInventoryUpload.generated_reports_folder, organization.id)
          else
            logger.info("Skipping automatic uploads for organization #{organization.name}, too many hosts (#{total_hosts}/#{ForemanInventoryUpload.max_org_size})")
          end
        end.compact
      ensure
        self.class.set(:wait => 24.hours).perform_later
      end

      def self.singleton_job_name
        name
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
foreman_rh_cloud-4.0.36 lib/foreman_inventory_upload/async/generate_all_reports_job.rb
foreman_rh_cloud-3.0.33 lib/foreman_inventory_upload/async/generate_all_reports_job.rb
foreman_rh_cloud-4.0.35 lib/foreman_inventory_upload/async/generate_all_reports_job.rb
foreman_rh_cloud-3.0.32 lib/foreman_inventory_upload/async/generate_all_reports_job.rb
foreman_rh_cloud-4.0.32 lib/foreman_inventory_upload/async/generate_all_reports_job.rb
foreman_rh_cloud-4.0.31 lib/foreman_inventory_upload/async/generate_all_reports_job.rb
foreman_rh_cloud-4.0.30 lib/foreman_inventory_upload/async/generate_all_reports_job.rb
foreman_rh_cloud-3.0.29 lib/foreman_inventory_upload/async/generate_all_reports_job.rb
foreman_rh_cloud-4.0.29 lib/foreman_inventory_upload/async/generate_all_reports_job.rb
foreman_rh_cloud-3.0.28 lib/foreman_inventory_upload/async/generate_all_reports_job.rb
foreman_rh_cloud-4.0.27 lib/foreman_inventory_upload/async/generate_all_reports_job.rb
foreman_rh_cloud-3.0.26 lib/foreman_inventory_upload/async/generate_all_reports_job.rb
foreman_rh_cloud-4.0.26 lib/foreman_inventory_upload/async/generate_all_reports_job.rb
foreman_rh_cloud-4.0.25.1 lib/foreman_inventory_upload/async/generate_all_reports_job.rb
foreman_rh_cloud-3.0.25 lib/foreman_inventory_upload/async/generate_all_reports_job.rb
foreman_rh_cloud-4.0.25 lib/foreman_inventory_upload/async/generate_all_reports_job.rb
foreman_rh_cloud-3.0.24.1 lib/foreman_inventory_upload/async/generate_all_reports_job.rb
foreman_rh_cloud-4.0.24.1 lib/foreman_inventory_upload/async/generate_all_reports_job.rb
foreman_rh_cloud-3.0.24 lib/foreman_inventory_upload/async/generate_all_reports_job.rb
foreman_rh_cloud-4.0.24 lib/foreman_inventory_upload/async/generate_all_reports_job.rb