Sha256: aaaf7a16094b2c95c9e8c6c9064355fc4fd067e947be668b75d1cfaa9ef7bcb3

Contents?: true

Size: 1.14 KB

Versions: 72

Compression:

Stored size: 1.14 KB

Contents

module CanvasSync
  module Jobs
    class SyncTermsJob < CanvasSync::Job
      # Syncs Terms using the Canvas API
      #
      # Terms are pre-synced so that provisioning reports can be scoped to term.
      #
      # @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)
        CanvasSync.get_canvas_sync_client(batch_context).terms("self", workflow_state: ['all']).all_pages!.each do |term_params|
          if account_id = batch_context[:account_id]
            # These branches are primarily to support Legacy apps
            if Term.respond_to?(:create_or_update) && Term.method(:create_or_update).arity.abs == 2
              Term.create_or_update(term_params, account_id)
            else
              term_params[:account_id] |= account_id
              update_or_create_model(Term, term_params)
            end
          else
            update_or_create_model(Term, term_params)
          end
        end

        TermBatchesJob.perform_now(options)
      end
    end
  end
end

Version data entries

72 entries across 72 versions & 1 rubygems

Version Path
canvas_sync-0.22.9 lib/canvas_sync/jobs/sync_terms_job.rb
canvas_sync-0.22.8 lib/canvas_sync/jobs/sync_terms_job.rb
canvas_sync-0.22.6 lib/canvas_sync/jobs/sync_terms_job.rb
canvas_sync-0.22.5 lib/canvas_sync/jobs/sync_terms_job.rb
canvas_sync-0.22.4 lib/canvas_sync/jobs/sync_terms_job.rb
canvas_sync-0.22.3 lib/canvas_sync/jobs/sync_terms_job.rb
canvas_sync-0.22.2 lib/canvas_sync/jobs/sync_terms_job.rb
canvas_sync-0.22.1 lib/canvas_sync/jobs/sync_terms_job.rb
canvas_sync-0.22.0 lib/canvas_sync/jobs/sync_terms_job.rb
canvas_sync-0.22.0.beta8 lib/canvas_sync/jobs/sync_terms_job.rb
canvas_sync-0.22.0.beta7 lib/canvas_sync/jobs/sync_terms_job.rb
canvas_sync-0.22.0.beta6 lib/canvas_sync/jobs/sync_terms_job.rb
canvas_sync-0.22.0.beta5 lib/canvas_sync/jobs/sync_terms_job.rb
canvas_sync-0.22.0.beta4 lib/canvas_sync/jobs/sync_terms_job.rb
canvas_sync-0.22.0.beta3 lib/canvas_sync/jobs/sync_terms_job.rb
canvas_sync-0.22.0.beta2 lib/canvas_sync/jobs/sync_terms_job.rb
canvas_sync-0.22.0.beta1 lib/canvas_sync/jobs/sync_terms_job.rb
canvas_sync-0.21.1 lib/canvas_sync/jobs/sync_terms_job.rb
canvas_sync-0.21.1.beta1 lib/canvas_sync/jobs/sync_terms_job.rb
canvas_sync-0.21.0 lib/canvas_sync/jobs/sync_terms_job.rb