Sha256: ae97a7f4bec27a623a8551170ef972773ef4a5b90245ff0388a01f1b8d579f9e
Contents?: true
Size: 748 Bytes
Versions: 13
Compression:
Stored size: 748 Bytes
Contents
class Marty::CronJob < ActiveJob::Base class << self def schedule return reschedule if scheduled? cron = cron_expression return if cron.blank? set(cron: cron).perform_later end def reschedule dj = delayed_job return dj.update(cron: cron_expression) if dj.locked_by? remove schedule end def remove delayed_job.destroy if scheduled? end alias remove_schedule remove def scheduled? delayed_job.present? end def delayed_job Delayed::Job. where('handler LIKE ?', "%job_class: #{name}\n%"). first end def cron_expression ::Marty::BackgroundJob::Schedule.on.find_by(job_class: name)&.cron end end end
Version data entries
13 entries across 13 versions & 1 rubygems