Sha256: b5a32241af0ef066ec18e484a5ab1df7e707c34756fab2c757b173d8d1fb6baa
Contents?: true
Size: 1.75 KB
Versions: 1
Compression:
Stored size: 1.75 KB
Contents
module CanvasSync module Jobs class SyncSimpleTableJob < ReportStarter # # Starts a report processor for the specified report # (the specified report must be enabled) # # @param job_chain [Hash] # @param options [Hash] def perform(job_chain, options) if options[:term_scope] sub_reports = CanvasSync.fork(@job_log, job_chain, keys: [:canvas_term_id]) do |fork_template| Term.send(options[:term_scope]).find_each.map do |term| fork = fork_template.duplicate # Deep copy the job_chain so each report gets the correct term id passed into # its options with no side effects term_id = get_term_id(term) fork[:global_options][:canvas_term_id] = term_id { job_chain: fork.serialize, params: report_params(options, term_id), options: options, } end end sub_reports.each do |r| start_report(r[:params], r[:job_chain], r[:options]) end else start_report(report_params(options), job_chain, options) end end def start_report(params, job_chain, options) CanvasSync::Jobs::ReportStarter.perform_later( job_chain, options[:report_name], params, CanvasSync::Processors::NormalProcessor.to_s, options, ) end def report_params(options, canvas_term_id=nil) params = options[:params] || {} params["parameters[enrollment_term_id]"] = canvas_term_id if canvas_term_id params end def get_term_id(term) term.try(:canvas_id) || term.canvas_term_id end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
canvas_sync-0.16.5 | lib/canvas_sync/jobs/sync_simple_table_job.rb |