Class: CanvasSync::Jobs::SyncAdminsJob

Inherits:
CanvasSync::Job show all
Defined in:
lib/canvas_sync/jobs/sync_admins_job.rb

Instance Attribute Summary

Attributes inherited from CanvasSync::Job

#job_log

Instance Method Summary collapse

Methods inherited from CanvasSync::Job

#create_job_log, #report_checker_wait_time, #update_or_create_model

Instance Method Details

#perform(options) ⇒ Object

Syncs Admins using the Canvas API

Parameters:

  • options (Hash)


8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/canvas_sync/jobs/sync_admins_job.rb', line 8

def perform(options)
  updated_admin_ids = []
  api_client = CanvasSync.get_canvas_sync_client(batch_context)
  CanvasSync.sync_scope(Account).find_each do |acc|
    api_client.(acc.canvas_id).all_pages_each do |admin_params|
      admin_params[:account_id] = acc.canvas_id
      admin = update_or_create_model(Admin, admin_params)
      updated_admin_ids.push(admin.id)
    end
  end
  Admin.where.not(id: updated_admin_ids).update_all(workflow_state: 'inactive')
end