Class: ForemanInventoryUpload::ReportsController

Inherits:
ApplicationController
  • Object
show all
Includes:
InventoryUpload::ReportActions
Defined in:
app/controllers/foreman_inventory_upload/reports_controller.rb

Instance Method Summary collapse

Methods included from InventoryUpload::ReportActions

#report_file, #start_report_generation

Instance Method Details

#generateObject



22
23
24
25
26
27
28
29
30
31
# File 'app/controllers/foreman_inventory_upload/reports_controller.rb', line 22

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

  start_report_generation(organization_id, disconnected)

  render json: {
    action_status: 'success',
  }, status: :ok
end

#lastObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/controllers/foreman_inventory_upload/reports_controller.rb', line 7

def last
  label = ForemanInventoryUpload::Async::GenerateReportJob.output_label(params[:organization_id])
  output = ForemanInventoryUpload::Async::ProgressOutput.get(label)&.full_output
  task_label = ForemanInventoryUpload::Async::GenerateAllReportsJob.name
  scheduled = ForemanTasks::Task.where(
    :label => task_label,
    :state => 'scheduled'
  ).first&.start_at || nil

  render json: {
    output: output,
    scheduled: scheduled,
  }, status: :ok
end