Sha256: bcb204b5d4630b318b3fb3843d653aa85979ed67ccbf8fad669816104dc6edd9

Contents?: true

Size: 1.14 KB

Versions: 1

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

1 entries across 1 versions & 1 rubygems

Version Path
foreman_inventory_upload-0.0.1.dev1 app/controllers/foreman_inventory_upload/statuses_controller.rb