From 46626e62a7017904c2ed584e92767b34e2c74c71 Mon Sep 17 00:00:00 2001 From: Corey Mc Date: Fri, 29 Sep 2023 00:01:25 +1000 Subject: [PATCH] Correct `discrete_execution#status` method (#1092) 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`) --- app/models/good_job/discrete_execution.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/good_job/discrete_execution.rb b/app/models/good_job/discrete_execution.rb index c90e777f6..7f88e73cf 100644 --- a/app/models/good_job/discrete_execution.rb +++ b/app/models/good_job/discrete_execution.rb @@ -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