Class: SpreeCmCommissioner::MaintenanceTask

Inherits:
Base
  • Object
show all
Includes:
StoreMetadata
Defined in:
app/models/spree_cm_commissioner/maintenance_task.rb

Constant Summary collapse

MAX_ATTEMPTS =
5

Instance Method Summary collapse

Instance Method Details

#async_executeObject



21
22
23
# File 'app/models/spree_cm_commissioner/maintenance_task.rb', line 21

def async_execute
  SpreeCmCommissioner::MaintenanceTasks::ProcessJob.perform_later(task_id: id)
end

#executeObject

Execute the maintenance task with error handling and attempt tracking



26
27
28
29
30
31
32
33
34
35
36
37
# File 'app/models/spree_cm_commissioner/maintenance_task.rb', line 26

def execute
  update(attempt_count: attempt_count + 1)

  maintain

  update!(completed_at: Time.current)

# Don't re-raise - continue processing other tasks
rescue StandardError => e
  update(last_error: e.message)
  log_failure(e)
end

#maintainObject

Override in subclasses with specific maintenance logic

Raises:

  • (NotImplementedError)


40
41
42
# File 'app/models/spree_cm_commissioner/maintenance_task.rb', line 40

def maintain
  raise NotImplementedError, "#{self.class} must implement #maintain"
end