Sha256: 5646a32579d392c2c35b00a2cb9f016022f3d34599b6086abf43c1e48e8162f7
Contents?: true
Size: 566 Bytes
Versions: 23
Compression:
Stored size: 566 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
23 entries across 23 versions & 1 rubygems