fix(cron): really schedule jobs on sidekiq instead of running them

This commit is contained in:
Colin Darie 2024-04-10 18:02:17 +02:00
parent e1144cf655
commit dfbe53dcc5
No known key found for this signature in database
GPG key ID: 8C76CADD40253590

View file

@ -4,14 +4,14 @@ class Cron::CronJob < ApplicationJob
class << self class << self
def schedulable? def schedulable?
true && ENV['CRON_JOBS_DISABLED'].blank? ENV['CRON_JOBS_DISABLED'].blank?
end end
def schedule def schedule
remove if cron_expression_changed? remove if cron_expression_changed?
if !scheduled? if !scheduled?
if queue_adapter == :sidekiq if queue_adapter_name == "sidekiq"
Sidekiq::Cron::Job.create(name: name, cron: cron_expression, class: name) Sidekiq::Cron::Job.create(name: name, cron: cron_expression, class: name)
else else
set(cron: cron_expression).perform_later set(cron: cron_expression).perform_later
@ -36,7 +36,7 @@ class Cron::CronJob < ApplicationJob
end end
def enqueued_cron_job def enqueued_cron_job
if queue_adapter == :sidekiq if queue_adapter_name == "sidekiq"
sidekiq_cron_job sidekiq_cron_job
else else
delayed_job delayed_job