Sha256: 803f8fecbc4dba112e37bc1360c4ad8a44b33dc924377093249985eaff58017a
Contents?: true
Size: 1.98 KB
Versions: 39
Compression:
Stored size: 1.98 KB
Contents
module CanvasSync module Jobs # Starts a Canvas report and enqueues a ReportChecker class ReportStarter < CanvasSync::Job # @param job_chain [Hash] # @param report_name [Hash] e.g., 'provisioning_csv' # @param report_params [Hash] The Canvas report parameters # @param processor [String] a stringified report processor class name # @param options [Hash] hash of options that will be passed to the job processor # @param allow_redownloads [Boolean] whether you want the job_chain to cache this report, # so that any later jobs in the chain will use the same generated report # @return [nil] def perform(job_chain, report_name, report_params, processor, options, allow_redownloads: false) account_id = options[:account_id] || job_chain[:global_options][:account_id] || "self" report_id = if allow_redownloads get_cached_report(job_chain, account_id, report_name, report_params) else start_report(job_chain, account_id, 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 private def get_cached_report(job_chain, account_id, report_name, report_params) if job_chain[:global_options][report_name].present? job_chain[:global_options][report_name] else report_id = start_report(job_chain, account_id, report_name, report_params) job_chain[:global_options][report_name] = report_id report_id end end def start_report(job_chain, account_id, report_name, report_params) report = CanvasSync.get_canvas_sync_client(job_chain[:global_options]) .start_report(account_id, report_name, report_params) report["id"] end end end end
Version data entries
39 entries across 39 versions & 1 rubygems