Skip to content

Commit b5debf8

Browse files
committed
Increase child batch count as new batches are enqueued, even in existing batches
1 parent 1599c92 commit b5debf8

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

lib/solid_queue/batch.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ def enqueue_batch(buffer)
6868
if batch_record.new_record?
6969
enqueue_new_batch(buffer)
7070
else
71-
jobs = buffer.jobs.values
72-
enqueue_existing_batch(jobs)
71+
enqueue_existing_batch(buffer)
7372
end
7473
end
7574

@@ -101,8 +100,9 @@ def enqueue_new_batch(buffer)
101100
end
102101
end
103102

104-
def enqueue_existing_batch(active_jobs)
105-
jobs = Array.wrap(active_jobs)
103+
def enqueue_existing_batch(buffer)
104+
jobs = buffer.jobs.values
105+
new_child_batches = buffer.child_batches.size
106106

107107
SolidQueue::BatchRecord.transaction do
108108
enqueued_count = SolidQueue::Job.enqueue_all(jobs)
@@ -111,8 +111,8 @@ def enqueue_existing_batch(active_jobs)
111111
SolidQueue::BatchExecution.track_job_creation(persisted_jobs, batch_id)
112112

113113
BatchRecord.where(batch_id: batch_id).update_all([
114-
"total_jobs = total_jobs + ?, pending_jobs = pending_jobs + ?",
115-
enqueued_count, enqueued_count
114+
"total_jobs = total_jobs + ?, pending_jobs = pending_jobs + ?, total_child_batches = total_child_batches + ?",
115+
enqueued_count, enqueued_count, new_child_batches
116116
])
117117
end
118118

0 commit comments

Comments
 (0)