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
|
|
|
|
2019-06-04 03:40:48 +00:00
|
|
|
class ScheduledTouchJob < ApplicationJob
|
2019-11-13 07:03:47 +00:00
|
|
|
include HasActiveJobLock
|
|
|
|
|
|
|
|
def lock_key
|
|
|
|
# "ScheduledTouchJob/User/42"
|
|
|
|
"#{self.class.name}/#{arguments[0]}/#{arguments[1]}"
|
2019-06-04 03:40:48 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def self.touch_at(object, date)
|
|
|
|
set(wait_until: date).perform_later(object.class.to_s, object.id)
|
|
|
|
end
|
2019-11-13 07:03:47 +00:00
|
|
|
|
|
|
|
def perform(klass_name, id)
|
|
|
|
klass_name.constantize.find_by(id: id)&.touch # rubocop:disable Rails/SkipsModelValidations
|
|
|
|
end
|
2019-06-04 03:40:48 +00:00
|
|
|
end
|