Sha256: a3eaf0a9843c3047d58ac7085e74802c5b1fe76b6eb3375ad20f844eb3b95b28

Contents?: true

Size: 864 Bytes

Versions: 35

Compression:

Stored size: 864 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)
      ForemanTasks.async_task(ForemanInventoryUpload::Async::GenerateReportJob, 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

35 entries across 35 versions & 1 rubygems

Version Path
foreman_rh_cloud-9.0.51 app/controllers/concerns/inventory_upload/report_actions.rb
foreman_rh_cloud-8.0.51 app/controllers/concerns/inventory_upload/report_actions.rb
foreman_rh_cloud-7.0.48 app/controllers/concerns/inventory_upload/report_actions.rb
foreman_rh_cloud-7.0.47 app/controllers/concerns/inventory_upload/report_actions.rb
foreman_rh_cloud-8.0.50 app/controllers/concerns/inventory_upload/report_actions.rb
foreman_rh_cloud-8.0.49 app/controllers/concerns/inventory_upload/report_actions.rb
foreman_rh_cloud-8.0.48 app/controllers/concerns/inventory_upload/report_actions.rb
foreman_rh_cloud-8.0.47 app/controllers/concerns/inventory_upload/report_actions.rb
foreman_rh_cloud-8.0.46 app/controllers/concerns/inventory_upload/report_actions.rb
foreman_rh_cloud-6.0.45 app/controllers/concerns/inventory_upload/report_actions.rb
foreman_rh_cloud-5.0.46 app/controllers/concerns/inventory_upload/report_actions.rb
foreman_rh_cloud-5.0.45 app/controllers/concerns/inventory_upload/report_actions.rb
foreman_rh_cloud-7.0.46 app/controllers/concerns/inventory_upload/report_actions.rb
foreman_rh_cloud-5.0.44 app/controllers/concerns/inventory_upload/report_actions.rb
foreman_rh_cloud-7.0.45 app/controllers/concerns/inventory_upload/report_actions.rb
foreman_rh_cloud-6.0.44 app/controllers/concerns/inventory_upload/report_actions.rb
foreman_rh_cloud-5.0.43 app/controllers/concerns/inventory_upload/report_actions.rb
foreman_rh_cloud-6.0.42.2 app/controllers/concerns/inventory_upload/report_actions.rb
foreman_rh_cloud-6.0.42.1 app/controllers/concerns/inventory_upload/report_actions.rb
foreman_rh_cloud-6.0.43 app/controllers/concerns/inventory_upload/report_actions.rb