Class: CanvasSync::Job
- Inherits:
-
ActiveJob::Base
- Object
- ActiveJob::Base
- CanvasSync::Job
- Defined in:
- lib/canvas_sync/job.rb
Overview
Inherit from this class to build a Job that will log to the canvas_sync_job_logs table
Direct Known Subclasses
CanvasSync::Jobs::BeginSyncChainJob, CanvasSync::Jobs::ReportChecker, CanvasSync::Jobs::ReportProcessorJob, CanvasSync::Jobs::ReportStarter, CanvasSync::Jobs::SyncAdminsJob, CanvasSync::Jobs::SyncRolesJob, CanvasSync::Jobs::SyncTermsJob, CanvasSync::Jobs::TermBatchesJob, LiveEvents::BaseHandler, LiveEvents::ProcessEventJob
Instance Attribute Summary collapse
-
#job_log ⇒ Object
readonly
Returns the value of attribute job_log.
Instance Method Summary collapse
- #create_job_log(job) ⇒ Object
- #report_checker_wait_time ⇒ Object
- #update_or_create_model(model, params) ⇒ Object
Instance Attribute Details
#job_log ⇒ Object (readonly)
Returns the value of attribute job_log.
6 7 8 |
# File 'lib/canvas_sync/job.rb', line 6 def job_log @job_log end |
Instance Method Details
#create_job_log(job) ⇒ Object
53 54 55 56 57 58 59 60 |
# File 'lib/canvas_sync/job.rb', line 53 def create_job_log(job) CanvasSync::JobLog.create( job_class: self.class.name, job_arguments: job.arguments, job_id: job.job_id, status: JobLog::ENQUEUED_STATUS, ) end |
#report_checker_wait_time ⇒ Object
49 50 51 |
# File 'lib/canvas_sync/job.rb', line 49 def report_checker_wait_time Rails.env.development? ? 1.second : 30.seconds end |
#update_or_create_model(model, params) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/canvas_sync/job.rb', line 62 def update_or_create_model(model, params) if model.respond_to? :create_or_update model.create_or_update(params) elsif model.method_defined? :update_from_api_params! instance = model.find_or_initialize_by(canvas_id: params['id']) instance.update_from_api_params!(params) instance else raise "Could not create/update #{model.name}. It must have a create_or_update(params) ClassMethod or implement ApiSyncable." end end |