Class: Workhorse::Jobs::CleanupSucceededJobs
- Inherits:
-
Object
- Object
- Workhorse::Jobs::CleanupSucceededJobs
- Defined in:
- lib/workhorse/jobs/cleanup_succeeded_jobs.rb
Overview
Job for cleaning up old succeeded jobs from the database. This maintenance job helps keep the jobs table from growing indefinitely by removing successfully completed jobs older than a specified age.
Instance Method Summary collapse
-
#initialize(max_age: 14) ⇒ CleanupSucceededJobs
constructor
Instantiates a new job.
-
#perform ⇒ void
Executes the cleanup by deleting old succeeded jobs.
Constructor Details
#initialize(max_age: 14) ⇒ CleanupSucceededJobs
Instantiates a new job.
17 18 19 |
# File 'lib/workhorse/jobs/cleanup_succeeded_jobs.rb', line 17 def initialize(max_age: 14) @max_age = max_age end |
Instance Method Details
#perform ⇒ void
This method returns an undefined value.
Executes the cleanup by deleting old succeeded jobs.
24 25 26 27 28 29 |
# File 'lib/workhorse/jobs/cleanup_succeeded_jobs.rb', line 24 def perform age_limit = seconds_ago(@max_age) Workhorse::DbJob.where( 'STATE = ? AND UPDATED_AT <= ?', Workhorse::DbJob::STATE_SUCCEEDED, age_limit ).delete_all end |