Class: CanvasSync::Jobs::SyncAdminsJob
- Inherits:
-
CanvasSync::Job
- Object
- ActiveJob::Base
- CanvasSync::Job
- CanvasSync::Jobs::SyncAdminsJob
- Defined in:
- lib/canvas_sync/jobs/sync_admins_job.rb
Instance Attribute Summary
Attributes inherited from CanvasSync::Job
Instance Method Summary collapse
-
#perform(options) ⇒ Object
Syncs Admins using the Canvas API.
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
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() updated_admin_ids = [] api_client = CanvasSync.get_canvas_sync_client(batch_context) CanvasSync.sync_scope(Account).find_each do |acc| api_client.account_admins(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 |