app/models/good_job/execution.rb in good_job-3.5.0 vs app/models/good_job/execution.rb in good_job-3.5.1

- old
+ new

@@ -64,11 +64,10 @@ { include: queues } end end belongs_to :job, class_name: 'GoodJob::Job', foreign_key: 'active_job_id', primary_key: 'active_job_id', optional: true, inverse_of: :executions - after_destroy -> { self.class.active_job_id(active_job_id).delete_all }, if: -> { @_destroy_job } # Get executions with given ActiveJob ID # @!method active_job_id # @!scope class # @param active_job_id [String] @@ -297,15 +296,15 @@ job_error = result.handled_error || result.unhandled_error self.error = [job_error.class, ERROR_MESSAGE_SEPARATOR, job_error.message].join if job_error if result.unhandled_error && GoodJob.retry_on_unhandled_error save! - elsif GoodJob.preserve_job_records == true || result.retried? || (result.unhandled_error && GoodJob.preserve_job_records == :on_unhandled_error) + elsif GoodJob.preserve_job_records == true || (result.unhandled_error && GoodJob.preserve_job_records == :on_unhandled_error) self.finished_at = Time.current save! else - destroy_job + destroy! end result end @@ -353,18 +352,10 @@ # Time between when this job started and finished def runtime_latency (finished_at || Time.zone.now) - performed_at if performed_at end - # Destroys this execution and all executions within the same job - def destroy_job - @_destroy_job = true - destroy! - ensure - @_destroy_job = false - end - private def active_job_data serialized_params.deep_dup .tap do |job_data| @@ -386,10 +377,10 @@ handled_error = value value = nil end handled_error ||= current_thread.error_on_retry || current_thread.error_on_discard - ExecutionResult.new(value: value, handled_error: handled_error, retried: current_thread.error_on_retry.present?) + ExecutionResult.new(value: value, handled_error: handled_error) rescue StandardError => e ExecutionResult.new(value: nil, unhandled_error: e) end end end