Class: CanvasSync::Jobs::ReportStarter

Inherits:
CanvasSync::Job show all
Defined in:
lib/canvas_sync/jobs/report_starter.rb

Overview

Starts a Canvas report and enqueues a ReportChecker

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_params, processor, options, allow_redownloads: false) ⇒ nil

Parameters:

  • job_chain (Hash)
  • report_name (Hash)

    e.g., ‘provisioning_csv’

  • report_params (Hash)

    The Canvas report parameters

  • processor (String)

    a stringified report processor class name

  • options (Hash)

    hash of options that will be passed to the job processor

  • allow_redownloads (Boolean) (defaults to: false)

    whether you want the job_chain to cache this report, so that any later jobs in the chain will use the same generated report

Returns:

  • (nil)


13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/canvas_sync/jobs/report_starter.rb', line 13

def perform(job_chain, report_name, report_params, processor, options, allow_redownloads: false)
   = options[:account_id] || job_chain[:global_options][:account_id] || "self"
	options[:sync_start_time] = DateTime.now.utc.iso8601
  report_id = if allow_redownloads
                get_cached_report(job_chain, , report_name, report_params)
              else
                start_report(job_chain, , report_name, report_params)
              end

  CanvasSync::Jobs::ReportChecker.set(wait: report_checker_wait_time).perform_later(
    job_chain,
    report_name,
    report_id,
    processor,
    options,
  )
end