lib/good_job.rb in good_job-2.99.0 vs lib/good_job.rb in good_job-3.0.0

- old
+ new

@@ -41,27 +41,25 @@ # GoodJob.logger = ActiveSupport::TaggedLogging.new(ActiveSupport::Logger.new("log/my_logs.log")) mattr_accessor :logger, default: DEFAULT_LOGGER # @!attribute [rw] preserve_job_records # @!scope class - # Whether to preserve job records in the database after they have finished (default: +false+). - # By default, GoodJob destroys job records after the job is completed successfully. + # Whether to preserve job records in the database after they have finished (default: +true+). + # By default, GoodJob deletes job records after the job is completed successfully. # If you want to preserve jobs for latter inspection, set this to +true+. # If you want to preserve only jobs that finished with error for latter inspection, set this to +:on_unhandled_error+. - # If +true+, you will need to clean out jobs using the +good_job cleanup_preserved_jobs+ CLI command or - # by using +Goodjob.cleanup_preserved_jobs+. # @return [Boolean, nil] - mattr_accessor :preserve_job_records, default: false + mattr_accessor :preserve_job_records, default: true # @!attribute [rw] retry_on_unhandled_error # @!scope class - # Whether to re-perform a job when a type of +StandardError+ is raised to GoodJob (default: +true+). + # Whether to re-perform a job when a type of +StandardError+ is raised to GoodJob (default: +false+). # If +true+, causes jobs to be re-queued and retried if they raise an instance of +StandardError+. # If +false+, jobs will be discarded or marked as finished if they raise an instance of +StandardError+. # Instances of +Exception+, like +SIGINT+, will *always* be retried, regardless of this attribute's value. # @return [Boolean, nil] - mattr_accessor :retry_on_unhandled_error, default: true + mattr_accessor :retry_on_unhandled_error, default: false # @!attribute [rw] on_thread_error # @!scope class # This callable will be called when an exception reaches GoodJob (default: +nil+). # It can be useful for logging errors to bug tracking services, like Sentry or Airbrake. @@ -141,10 +139,10 @@ older_than ||= configuration.cleanup_preserved_jobs_before_seconds_ago timestamp = Time.current - older_than include_discarded = configuration.cleanup_discarded_jobs? ActiveSupport::Notifications.instrument("cleanup_preserved_jobs.good_job", { older_than: older_than, timestamp: timestamp }) do |payload| - old_jobs = GoodJob::ActiveJobJob.where('finished_at <= ?', timestamp) + old_jobs = GoodJob::Job.where('finished_at <= ?', timestamp) old_jobs = old_jobs.not_discarded unless include_discarded old_jobs_count = old_jobs.count GoodJob::Execution.where(job: old_jobs).destroy_all payload[:destroyed_records_count] = old_jobs_count