Skip to content

Commit

Permalink
Add a version check for Rails whether to use pg interval or calculate…
Browse files Browse the repository at this point in the history
… float
  • Loading branch information
bensheldon committed Jul 6, 2024
1 parent 94b672c commit eceebcc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion app/models/good_job/discrete_execution.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ def queue_latency

# Monotonic time between when this job started and finished
def runtime_latency
if self.class.monotonic_duration_migrated?
# migrated and Rails greater than 6.1
if self.class.monotonic_duration_migrated? && Gem::Version.new(Rails.version) >= Gem::Version.new('6.1.0.a')
duration
elsif performed_at
(finished_at || Time.current) - performed_at
Expand Down
2 changes: 1 addition & 1 deletion app/models/good_job/execution.rb
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ def perform(lock_id:)
job_attributes[:finished_at] = job_finished_at
if discrete_execution
discrete_execution.finished_at = job_finished_at
discrete_execution.duration = monotonic_duration if GoodJob::DiscreteExecution.monotonic_duration_migrated?
discrete_execution.duration = monotonic_duration if GoodJob::DiscreteExecution.monotonic_duration_migrated? && Gem::Version.new(Rails.version) >= Gem::Version.new('6.1.0.a')
end

retry_unhandled_error = result.unhandled_error && GoodJob.retry_on_unhandled_error
Expand Down

0 comments on commit eceebcc

Please sign in to comment.