2022-01-01 13:38:12 +00:00
|
|
|
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
|
2021-06-01 12:20:20 +00:00
|
|
|
|
2020-01-08 14:57:17 +00:00
|
|
|
class ActiveJobLock < ActiveRecord::Base
|
2019-11-13 07:03:47 +00:00
|
|
|
|
|
|
|
def of?(active_job)
|
|
|
|
active_job.job_id == active_job_id
|
|
|
|
end
|
|
|
|
|
|
|
|
def peform_pending?
|
|
|
|
updated_at == created_at
|
|
|
|
end
|
|
|
|
|
|
|
|
def transfer_to(active_job)
|
2021-05-10 14:18:43 +00:00
|
|
|
logger.debug { "Transferring ActiveJobLock with id '#{id}' from active_job_id '#{active_job_id}' to active_job_id '#{active_job_id}'." }
|
2019-11-13 07:03:47 +00:00
|
|
|
|
|
|
|
reset_time_stamp = Time.zone.now
|
|
|
|
update!(
|
|
|
|
active_job_id: active_job.job_id,
|
|
|
|
created_at: reset_time_stamp,
|
|
|
|
updated_at: reset_time_stamp
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|