Skip to content

Commit

Permalink
Use keyword arg to control whether we reenqueue
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianna-chang-shopify committed Mar 1, 2021
1 parent a2500ac commit 62397b3
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions app/jobs/maintenance_tasks/task_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class TaskJob < ActiveJob::Base
on_complete(:on_complete)
on_shutdown(:on_shutdown)

after_perform(:after_perform, prepend: true)
after_perform(:after_perform)

rescue_from StandardError, with: :on_error

Expand Down Expand Up @@ -104,17 +104,16 @@ def on_shutdown
unless private_method_defined?(:reenqueue_iteration_job)
raise 'JobIteration::Iteration#reenqueue_iteration_job must be defined'
end
def reenqueue_iteration_job
if defined?(@reenqueue_iteration_job) && @reenqueue_iteration_job
super
else
@reenqueue_iteration_job = true
end
def reenqueue_iteration_job(should_ignore: true)
super() unless should_ignore
@reenqueue_iteration_job = true
end

def after_perform
@run.save!
reenqueue_iteration_job
if defined?(@reenqueue_iteration_job) && @reenqueue_iteration_job
reenqueue_iteration_job(should_ignore: false)
end
end

def on_error(error)
Expand Down

0 comments on commit 62397b3

Please sign in to comment.