Skip to content

Commit

Permalink
Add ability to generate report without uploading
Browse files Browse the repository at this point in the history
  • Loading branch information
chris1984 committed Oct 23, 2023
1 parent 5bf9938 commit 4ed3044
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
4 changes: 3 additions & 1 deletion app/controllers/api/v2/rh_cloud/inventory_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ def download_file

api :POST, "/organizations/:organization_id/rh_cloud/report", N_("Start report generation")
param :organization_id, Integer, required: true, desc: N_("Set the current organization context for the request")
param :disconnected, :bool, required: false, desc: N_('Generate the report, but do not upload')
def generate_report
organization_id = params[:organization_id]
disconnected = params[:disconnected]

start_report_generation(organization_id)
start_report_generation(organization_id, disconnected)

render json: {
action_status: 'success',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def initialize(**params)
end
end

def start_report_generation(organization_id)
def start_report_generation(organization_id, disconnected)
ForemanTasks.async_task(ForemanInventoryUpload::Async::GenerateReportJob, ForemanInventoryUpload.generated_reports_folder, organization_id)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ def last

def generate
organization_id = params[:organization_id]
disconnected = params[:disconnected]

start_report_generation(organization_id)
start_report_generation(organization_id, disconnected)

render json: {
action_status: 'success',
Expand Down
6 changes: 4 additions & 2 deletions lib/foreman_inventory_upload/async/generate_report_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ def self.output_label(label)
"report_for_#{label}"
end

def plan(base_folder, organization_id)
def plan(base_folder, organization_id, disconnected)
# rubocop:disable Style/MultilineIfModifier
sequence do
super(
GenerateReportJob.output_label(organization_id),
Expand All @@ -18,8 +19,9 @@ def plan(base_folder, organization_id)
base_folder,
ForemanInventoryUpload.facts_archive_name(organization_id),
organization_id
)
) unless disconnected
end
# rubocop:enable Style/MultilineIfModifier
end

def rake_prefix
Expand Down

0 comments on commit 4ed3044

Please sign in to comment.