Sha256: 6959fe68c3e6a4e73de6964fa9cdeddd8cf3dc910d5495a26bd230e424d3df06

Contents?: true

Size: 1.14 KB

Versions: 7

Compression:

Stored size: 1.14 KB

Contents

module ForemanInventoryUpload
  class StatusesController < ::ApplicationController
    # override default "welcome screen behavior, since we don't have a model"
    def welcome
      true
    end

    def index
      portal_users = RedhatAccess::TelemetryConfiguration
                     .where(enable_telemetry: true)
                     .distinct
                     .pluck(:portal_user)

      statuses = Hash[
        portal_users.map do |portal_user|
          generate_report_status = status_for(portal_user, ForemanInventoryUpload::Async::GenerateReportJob)
          upload_report_status = status_for(portal_user, ForemanInventoryUpload::Async::UploadReportJob)

          [
            portal_user,
            {
              generate_report_status: generate_report_status,
              upload_report_status: upload_report_status,
            },
          ]
        end
      ]

      render json: {
        statuses: statuses,
      }, status: :ok
    end

    private

    def status_for(portal_user, job_class)
      label = job_class.output_label(portal_user)
      ForemanInventoryUpload::Async::ProgressOutput.get(label)&.status
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
foreman_inventory_upload-1.0.0.beta7 app/controllers/foreman_inventory_upload/statuses_controller.rb
foreman_inventory_upload-1.0.0.beta6 app/controllers/foreman_inventory_upload/statuses_controller.rb
foreman_inventory_upload-1.0.0.beta5 app/controllers/foreman_inventory_upload/statuses_controller.rb
foreman_inventory_upload-1.0.0.beta4 app/controllers/foreman_inventory_upload/statuses_controller.rb
foreman_inventory_upload-1.0.0.beta3 app/controllers/foreman_inventory_upload/statuses_controller.rb
foreman_inventory_upload-1.0.0.beta2 app/controllers/foreman_inventory_upload/statuses_controller.rb
foreman_inventory_upload-1.0.0.beta1 app/controllers/foreman_inventory_upload/statuses_controller.rb