scheduled_touch_job.rb 506 B

123456789101112131415161718
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class ScheduledTouchJob < ApplicationJob
  3. include HasActiveJobLock
  4. def lock_key
  5. # "ScheduledTouchJob/User/42"
  6. "#{self.class.name}/#{arguments[0]}/#{arguments[1]}"
  7. end
  8. def self.touch_at(object, date)
  9. set(wait_until: date).perform_later(object.class.to_s, object.id)
  10. end
  11. def perform(klass_name, id)
  12. klass_name.constantize.find_by(id: id)&.touch # rubocop:disable Rails/SkipsModelValidations
  13. end
  14. end