module CanvasSync module Jobs # ActiveJob class that starts a Canvas provisioning report class SyncProvisioningReportJob < CanvasSync::Job # @param options [Hash] If options contains a :term_scope a seperate provisioning report # will be started for each term in that scope. :models should be an array of # models to sync. def perform(options) start_report(report_params(options), options) end protected def start_report(report_params, options) CanvasSync::Jobs::ReportStarter.perform_later( "proservices_provisioning_csv", report_params, CanvasSync::Processors::ProvisioningReportProcessor.to_s, options, ) end def report_params(options, canvas_term_id = options[:canvas_term_id] || batch_context[:canvas_term_id]) params = { include_deleted: true, } options[:models].each do |model| # group_membership is the only model param that is singular :( model = 'group_membership' if model == 'group_memberships' params[model] = true end params[:enrollment_term_id] = canvas_term_id if canvas_term_id params.merge!(options[:report_parameters]) if options[:report_parameters].present? { parameters: params } end end end end