Sha256: f41f7e850c705cab4752eccaa1677c9a1c65f3bac6a54f7405f377323c9d943c

Contents?: true

Size: 853 Bytes

Versions: 22

Compression:

Stored size: 853 Bytes

Contents

module InventoryUpload
  module ReportActions
    extend ActiveSupport::Concern

    class ReportMissingError < Foreman::Exception
      MESSAGE = N_("The report file %{filename} doesn't exist")

      def initialize(**params)
        super(self.class::MESSAGE % params, params)
      end
    end

    def start_report_generation(organization_id)
      ForemanInventoryUpload::Async::GenerateReportJob.perform_later(ForemanInventoryUpload.generated_reports_folder, organization_id)
    end

    def report_file(organization_id)
      filename = ForemanInventoryUpload.facts_archive_name(organization_id)
      files = Dir["{#{ForemanInventoryUpload.uploads_file_path(filename)},#{ForemanInventoryUpload.done_file_path(filename)}}"]

      raise ReportMissingError.new(filename: filename) if files.empty?

      [filename, files.first]
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
foreman_rh_cloud-4.0.36 app/controllers/concerns/inventory_upload/report_actions.rb
foreman_rh_cloud-3.0.33 app/controllers/concerns/inventory_upload/report_actions.rb
foreman_rh_cloud-4.0.35 app/controllers/concerns/inventory_upload/report_actions.rb
foreman_rh_cloud-3.0.32 app/controllers/concerns/inventory_upload/report_actions.rb
foreman_rh_cloud-4.0.32 app/controllers/concerns/inventory_upload/report_actions.rb
foreman_rh_cloud-4.0.31 app/controllers/concerns/inventory_upload/report_actions.rb
foreman_rh_cloud-4.0.30 app/controllers/concerns/inventory_upload/report_actions.rb
foreman_rh_cloud-3.0.29 app/controllers/concerns/inventory_upload/report_actions.rb
foreman_rh_cloud-4.0.29 app/controllers/concerns/inventory_upload/report_actions.rb
foreman_rh_cloud-3.0.28 app/controllers/concerns/inventory_upload/report_actions.rb
foreman_rh_cloud-4.0.27 app/controllers/concerns/inventory_upload/report_actions.rb
foreman_rh_cloud-3.0.26 app/controllers/concerns/inventory_upload/report_actions.rb
foreman_rh_cloud-4.0.26 app/controllers/concerns/inventory_upload/report_actions.rb
foreman_rh_cloud-4.0.25.1 app/controllers/concerns/inventory_upload/report_actions.rb
foreman_rh_cloud-3.0.25 app/controllers/concerns/inventory_upload/report_actions.rb
foreman_rh_cloud-4.0.25 app/controllers/concerns/inventory_upload/report_actions.rb
foreman_rh_cloud-3.0.24.1 app/controllers/concerns/inventory_upload/report_actions.rb
foreman_rh_cloud-4.0.24.1 app/controllers/concerns/inventory_upload/report_actions.rb
foreman_rh_cloud-3.0.24 app/controllers/concerns/inventory_upload/report_actions.rb
foreman_rh_cloud-4.0.24 app/controllers/concerns/inventory_upload/report_actions.rb