active_job_lock.rb 600 B

1234567891011121314151617181920212223
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class ActiveJobLock < ActiveRecord::Base
  3. def of?(active_job)
  4. active_job.job_id == active_job_id
  5. end
  6. def peform_pending?
  7. updated_at == created_at
  8. end
  9. def transfer_to(active_job)
  10. logger.debug { "Transferring ActiveJobLock with id '#{id}' from active_job_id '#{active_job_id}' to active_job_id '#{active_job_id}'." }
  11. reset_time_stamp = Time.zone.now
  12. update!(
  13. active_job_id: active_job.job_id,
  14. created_at: reset_time_stamp,
  15. updated_at: reset_time_stamp
  16. )
  17. end
  18. end