Sha256: af1d626ad2797009562606bf5f8db63c609f287163edb6084ae7054eb5c8ce2d

Contents?: true

Size: 1.69 KB

Versions: 36

Compression:

Stored size: 1.69 KB

Contents

module CanvasSync
  module Jobs
    # ActiveJob class used to check the status of a pending Canvas report.
    # Re-enqueues itself if the report is still processing on Canvas.
    # Enqueues the ReportProcessor when the report has completed.
    class ReportChecker < CanvasSync::Job
      # @param report_name [Hash] e.g., 'provisioning_csv'
      # @param report_id [Integer]
      # @param processor [String] a stringified report processor class name
      # @param options [Hash] hash of options that will be passed to the job processor
      # @return [nil]
      def perform(report_name, report_id, processor, options) # rubocop:disable Metrics/AbcSize
        account_id = options[:account_id] || batch_context[:account_id] || "self"
        report_status = CanvasSync.get_canvas_sync_client(batch_context)
                                  .report_status(account_id, report_name, report_id)

        case report_status["status"].downcase
        when "complete"
          CanvasSync::Jobs::ReportProcessorJob.perform_later(
            report_name,
            report_status["attachment"]["url"],
            processor,
            options,
            report_id,
          )
        when "error", "deleted"
          message = "Report failed to process; status was #{report_status} for report_name: #{report_name}, report_id: #{report_id}" # rubocop:disable Metrics/LineLength
          Rails.logger.error(message)
          raise message
        else
          CanvasSync::Jobs::ReportChecker
            .set(wait: report_checker_wait_time)
            .perform_later(
              report_name,
              report_id,
              processor,
              options,
            )
        end
      end
    end
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
canvas_sync-0.17.10.beta2 lib/canvas_sync/jobs/report_checker.rb
canvas_sync-0.17.10.beta1 lib/canvas_sync/jobs/report_checker.rb
canvas_sync-0.17.8 lib/canvas_sync/jobs/report_checker.rb
canvas_sync-0.17.8.beta4 lib/canvas_sync/jobs/report_checker.rb
canvas_sync-0.17.8.beta3 lib/canvas_sync/jobs/report_checker.rb
canvas_sync-0.17.8.beta2 lib/canvas_sync/jobs/report_checker.rb
canvas_sync-0.17.8.beta1 lib/canvas_sync/jobs/report_checker.rb
canvas_sync-0.17.7 lib/canvas_sync/jobs/report_checker.rb
canvas_sync-0.17.7.beta1 lib/canvas_sync/jobs/report_checker.rb
canvas_sync-0.17.6 lib/canvas_sync/jobs/report_checker.rb
canvas_sync-0.17.6.beta1 lib/canvas_sync/jobs/report_checker.rb
canvas_sync-0.17.5 lib/canvas_sync/jobs/report_checker.rb
canvas_sync-0.17.5.beta2 lib/canvas_sync/jobs/report_checker.rb
canvas_sync-0.17.5.beta1 lib/canvas_sync/jobs/report_checker.rb
canvas_sync-0.17.4 lib/canvas_sync/jobs/report_checker.rb
canvas_sync-0.17.3.beta3 lib/canvas_sync/jobs/report_checker.rb
canvas_sync-0.17.3.beta2 lib/canvas_sync/jobs/report_checker.rb
canvas_sync-0.17.3.beta1 lib/canvas_sync/jobs/report_checker.rb
canvas_sync-0.17.2 lib/canvas_sync/jobs/report_checker.rb
canvas_sync-0.17.1 lib/canvas_sync/jobs/report_checker.rb