Class: CanvasSync::Jobs::ReportProcessorJob

Inherits:
CanvasSync::Job
  • Object
show all
Defined in:
lib/canvas_sync/jobs/report_processor_job.rb

Overview

ActiveJob class that wraps around a report processor. This job will download the report, and then pass the file path and options into the process method on the processor.

Instance Attribute Summary

Attributes inherited from CanvasSync::Job

#job_chain, #job_log

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_url, processor, options, report_id) ⇒ nil

Parameters:

  • job_chain (Hash)
  • report_name (Hash)

    e.g., ‘provisioning_csv’

  • report_url (String)
  • processor (String)

    a stringified report processor class name

  • options (Hash)

    hash of options that will be passed to the job processor

Returns:

  • (nil)


15
16
17
18
19
20
21
22
23
24
25
# File 'lib/canvas_sync/jobs/report_processor_job.rb', line 15

def perform(job_chain, report_name, report_url, processor, options, report_id)
  @job_log.update_attributes(job_class: processor)
  download(report_name, report_url) do |file_path|
    options = job_chain[:global_options].merge(options).merge({
      report_processor_job_id: @job_log.job_id
    })
    processor.constantize.process(file_path, options, report_id)
  end

  CanvasSync.invoke_next(job_chain)
end