Skip to content

Commit

Permalink
Fix GoodJob.cleanup_preserved_jobs to add missing guard for unmigra…
Browse files Browse the repository at this point in the history
…ted discrete executions (#938)
  • Loading branch information
bensheldon authored Apr 24, 2023
1 parent bf112c2 commit f6e5c24
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/good_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,10 @@ def self.cleanup_preserved_jobs(older_than: nil, in_batches_of: 1_000)
active_job_ids = jobs_query.pluck(:active_job_id)
break if active_job_ids.empty?

deleted_discrete_executions = GoodJob::DiscreteExecution.where(active_job_id: active_job_ids).delete_all
deleted_discrete_executions_count += deleted_discrete_executions
if GoodJob::Execution.discrete_support?
deleted_discrete_executions = GoodJob::DiscreteExecution.where(active_job_id: active_job_ids).delete_all
deleted_discrete_executions_count += deleted_discrete_executions
end

deleted_executions = GoodJob::Execution.where(active_job_id: active_job_ids).delete_all
deleted_executions_count += deleted_executions
Expand Down

0 comments on commit f6e5c24

Please sign in to comment.