Sha256: ec523dc486bf3322a31690654b23d4b2c9c7ed323c78372b1478f99fccc983d8
Contents?: true
Size: 1.78 KB
Versions: 13
Compression:
Stored size: 1.78 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 |job_chain| Term.send(options[:term_scope]).find_each.map do |term| # 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) duped_job_chain = Marshal.load(Marshal.dump(job_chain)) duped_job_chain[:global_options][:canvas_term_id] = term_id { job_chain: duped_job_chain, 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
13 entries across 13 versions & 1 rubygems