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-3.0.23 lib/foreman_inventory_upload/async/generate_all_reports_job.rb
foreman_rh_cloud-4.0.23 lib/foreman_inventory_upload/async/generate_all_reports_job.rb
foreman_rh_cloud-3.0.22 lib/foreman_inventory_upload/async/generate_all_reports_job.rb
foreman_rh_cloud-4.0.22 lib/foreman_inventory_upload/async/generate_all_reports_job.rb
foreman_rh_cloud-4.0.21.1 lib/foreman_inventory_upload/async/generate_all_reports_job.rb
foreman_rh_cloud-3.0.21.1 lib/foreman_inventory_upload/async/generate_all_reports_job.rb
foreman_rh_cloud-3.0.21 lib/foreman_inventory_upload/async/generate_all_reports_job.rb