Class: CanvasSync::Jobs::ReportChecker
- Inherits:
-
CanvasSync::Job
- Object
- ActiveJob::Base
- CanvasSync::Job
- CanvasSync::Jobs::ReportChecker
- Defined in:
- lib/canvas_sync/jobs/report_checker.rb
Overview
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.
Instance Attribute Summary
Attributes inherited from CanvasSync::Job
Instance Method Summary collapse
Methods inherited from CanvasSync::Job
#create_job_log, #report_checker_wait_time, #update_or_create_model
Instance Method Details
#perform(job_chain, report_name, report_id, processor, options) ⇒ nil
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/canvas_sync/jobs/report_checker.rb', line 13 def perform(job_chain, report_name, report_id, processor, ) # rubocop:disable Metrics/AbcSize account_id = [: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, , report_id, ) when "error", "deleted" = "Report failed to process; status was #{report_status} for report_name: #{report_name}, report_id: #{report_id}" # rubocop:disable Metrics/LineLength Rails.logger.error() raise else CanvasSync::Jobs::ReportChecker .set(wait: report_checker_wait_time) .perform_later( job_chain, report_name, report_id, processor, , ) end end |