Sha256: 1438f65c6a9c672671ca488c7aa4f8147ff3d1cb0b90bc899b9a82da47d9e5b2
Contents?: true
Size: 568 Bytes
Versions: 10
Compression:
Stored size: 568 Bytes
Contents
module Workhorse::Jobs class CleanupSucceededJobs # Instantiates a new job. # # @param max_age [Integer] The maximal age of jobs to retain, in days. Will # be evaluated at perform time. def initialize(max_age: 14) @max_age = max_age end def perform age_limit = seconds_ago(@max_age) Workhorse::DbJob.where( 'STATE = ? AND UPDATED_AT <= ?', Workhorse::DbJob::STATE_SUCCEEDED, age_limit ).delete_all end private def seconds_ago(days) Time.now - (days * 24 * 60 * 60) end end end
Version data entries
10 entries across 10 versions & 1 rubygems