Skip to content

Commit

Permalink
Correct discrete_execution#status method (#1092)
Browse files Browse the repository at this point in the history
The order of the conditions in this `discrete_execution#status` method was previously incorrect, which meant it was not possible for the `:discarded` status to ever be returned

If `error.present?` then the status should either be `:retried` or `:discarded`, depending on whether the parent job has a `finished_at` timestamp. However, the more specific check of `error.present? && job.finished_at.present?` was left in the `elsif` branch. That meant the value of `:retried` was always returned whenever the more generic `if error.present?` condition returned true (without ever checking the value of `job.finished_at`)
  • Loading branch information
coreyaus authored Sep 28, 2023
1 parent 98d022f commit 46626e6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/models/good_job/discrete_execution.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ def last_status_at

def status
if finished_at.present?
if error.present?
:retried
elsif error.present? && job.finished_at.present?
if error.present? && job.finished_at.present?
:discarded
elsif error.present?
:retried
else
:succeeded
end
Expand Down

0 comments on commit 46626e6

Please sign in to comment.