Sha256: df437035f774ab1647835c4b68d61adafc85313c67767ed14bb0425dd1e6dad6

Contents?: true

Size: 1.79 KB

Versions: 22

Compression:

Stored size: 1.79 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 job_chain [Hash]
      # @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(job_chain, report_name, report_id, processor, options) # rubocop:disable Metrics/AbcSize
        account_id = options[:account_id] || job_chain[:global_options][:account_id] || "self"
        report_status = CanvasSync.get_canvas_sync_client(job_chain[:global_options])
                                  .report_status(account_id, report_name, report_id)

        case report_status["status"].downcase
        when "complete"
          CanvasSync::Jobs::ReportProcessorJob.perform_later(
            job_chain,
            report_name,
            report_status["attachment"]["url"],
            processor,
            options,
          )
        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(
              job_chain,
              report_name,
              report_id,
              processor,
              options,
            )
        end
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
canvas_sync-0.6.4 lib/canvas_sync/jobs/report_checker.rb
canvas_sync-0.6.3 lib/canvas_sync/jobs/report_checker.rb
canvas_sync-0.6.2 lib/canvas_sync/jobs/report_checker.rb
canvas_sync-0.6.1 lib/canvas_sync/jobs/report_checker.rb
canvas_sync-0.6.0 lib/canvas_sync/jobs/report_checker.rb
canvas_sync-0.5.4 lib/canvas_sync/jobs/report_checker.rb
canvas_sync-0.5.3 lib/canvas_sync/jobs/report_checker.rb
canvas_sync-0.5.2 lib/canvas_sync/jobs/report_checker.rb
canvas_sync-0.5.1 lib/canvas_sync/jobs/report_checker.rb
canvas_sync-0.4.1 lib/canvas_sync/jobs/report_checker.rb
canvas_sync-0.4.0 lib/canvas_sync/jobs/report_checker.rb
canvas_sync-0.3.23 lib/canvas_sync/jobs/report_checker.rb
canvas_sync-0.3.22 lib/canvas_sync/jobs/report_checker.rb
canvas_sync-0.3.21 lib/canvas_sync/jobs/report_checker.rb
canvas_sync-0.3.20 lib/canvas_sync/jobs/report_checker.rb
canvas_sync-0.3.19 lib/canvas_sync/jobs/report_checker.rb
canvas_sync-0.3.18 lib/canvas_sync/jobs/report_checker.rb
canvas_sync-0.3.17 lib/canvas_sync/jobs/report_checker.rb
canvas_sync-0.3.16 lib/canvas_sync/jobs/report_checker.rb
canvas_sync-0.3.15 lib/canvas_sync/jobs/report_checker.rb