demarches-normaliennes/lib/tasks/jobs.rake
2024-08-22 09:26:48 +02:00

19 lines
509 B
Ruby

# frozen_string_literal: true
namespace :jobs do
desc 'Schedule all schedulable cron jobs'
task schedule: :environment do
schedulable_jobs.each(&:schedule)
end
desc 'Display schedule for all schedulable cron jobs'
task display_schedule: :environment do
schedulable_jobs.each(&:display_schedule)
end
def schedulable_jobs
glob = Rails.root.join('app', 'jobs', '**', '*_job.rb')
Dir.glob(glob).each { |f| require f }
Cron::CronJob.subclasses.filter(&:schedulable?)
end
end