add schedulable? class method to cron jobs
This commit is contained in:
parent
bed6167010
commit
0e3e6eb62a
4 changed files with 30 additions and 0 deletions
|
@ -3,6 +3,10 @@ class Cron::CronJob < ApplicationJob
|
|||
class_attribute :schedule_expression
|
||||
|
||||
class << self
|
||||
def schedulable?
|
||||
true
|
||||
end
|
||||
|
||||
def schedule
|
||||
remove if cron_expression_changed?
|
||||
set(cron: cron_expression).perform_later if !scheduled?
|
||||
|
|
|
@ -15,4 +15,8 @@ class Cron::Datagouv::ExportAndPublishDemarchesPubliquesJob < Cron::CronJob
|
|||
FileUtils.rm(gzip_filepath)
|
||||
end
|
||||
end
|
||||
|
||||
def self.schedulable?
|
||||
ENV.fetch('OPENDATA_ENABLED', nil) == 'enabled'
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue