Skip to content

Commit af2bdc1

Browse files
committed
Support rails versions that don't have after_all_transactions_commit
1 parent 8565c3a commit af2bdc1

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

app/models/solid_queue/batch.rb

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,12 @@ def enqueue(&block)
3333
block.call(self)
3434
end
3535

36-
ActiveRecord.after_all_transactions_commit do
37-
enqueue_empty_job if reload.total_jobs == 0
38-
enqueue_monitor_job
36+
if ActiveSupport.respond_to?(:after_all_transactions_commit)
37+
ActiveRecord.after_all_transactions_commit do
38+
start_monitoring
39+
end
40+
else
41+
start_monitoring
3942
end
4043
end
4144

@@ -141,6 +144,11 @@ def enqueue_monitor_job
141144
end
142145
end
143146

147+
def start_monitoring
148+
enqueue_empty_job if reload.total_jobs == 0
149+
enqueue_monitor_job
150+
end
151+
144152
class << self
145153
def enqueue(on_success: nil, on_failure: nil, on_finish: nil, metadata: nil, &block)
146154
new.tap do |batch|

0 commit comments

Comments
 (0)