Class: ChronoForge::CleanupJob
- Inherits:
-
ActiveJob::Base
- Object
- ActiveJob::Base
- ChronoForge::CleanupJob
- Defined in:
- lib/chrono_forge/cleanup_job.rb
Overview
ActiveJob wrapper around Cleanup so the cleanup can be enqueued and scheduled with any recurring-job mechanism (Solid Queue recurring tasks, sidekiq-cron, GoodJob cron, …).
Arguments are plain scalars (day counts) rather than ActiveSupport::Duration objects so the job can be configured from YAML/cron config files, which can only carry primitive values:
ChronoForge::CleanupJob.perform_later(
older_than_days: 90,
failed_older_than_days: 180,
prune_repetition_logs_older_than_days: 30
)
Instance Method Summary collapse
Instance Method Details
#perform(older_than_days: nil, completed_older_than_days: nil, failed_older_than_days: nil, prune_repetition_logs_older_than_days: nil, batch_size: nil) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/chrono_forge/cleanup_job.rb', line 16 def perform(older_than_days: nil, completed_older_than_days: nil, failed_older_than_days: nil, prune_repetition_logs_older_than_days: nil, batch_size: nil) = {} [:older_than] = older_than_days.to_i.days if older_than_days [:completed_older_than] = completed_older_than_days.to_i.days if completed_older_than_days [:failed_older_than] = failed_older_than_days.to_i.days if failed_older_than_days if prune_repetition_logs_older_than_days [:prune_repetition_logs_older_than] = prune_repetition_logs_older_than_days.to_i.days end [:batch_size] = batch_size.to_i if batch_size Cleanup.run(**) end |