Class: CanvasSync::Jobs::SyncRolesJob
- Inherits:
 - 
      CanvasSync::Job
      
        
- Object
 - ActiveJob::Base
 - CanvasSync::Job
 - CanvasSync::Jobs::SyncRolesJob
 
 
- Defined in:
 - lib/canvas_sync/jobs/sync_roles_job.rb
 
Instance Attribute Summary
Attributes inherited from CanvasSync::Job
Instance Method Summary collapse
- 
  
    
      #perform(options)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Syncs Roles 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 Roles using the Canvas API
      7 8 9 10 11 12 13 14 15 16 17  | 
    
      # File 'lib/canvas_sync/jobs/sync_roles_job.rb', line 7 def perform() updated_role_ids = [] api_client = CanvasSync.get_canvas_sync_client(batch_context) CanvasSync.sync_scope(Account).find_each do |acc| api_client.list_roles(acc.canvas_id, state: %w[active inactive]).all_pages_each do |role_params| role = update_or_create_model(Role, role_params) updated_role_ids.push(role.id) end end Role.where.not(id: updated_role_ids).update_all(workflow_state: 'inactive') end  |