Skip to content

Commit 3b9aee6

Browse files
authored
Merge pull request #7 from jaystep/return-job-ids
Return the enqueued job ids from push_back
2 parents 9d6c621 + a331102 commit 3b9aee6

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

lib/sidekiq/bulk.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
module SidekiqBulk
44
def push_bulk(items, limit: 10_000, &block)
5-
items.each_slice(limit).each do |group|
5+
job_ids = items.each_slice(limit).map do |group|
66
push_bulk!(group, &block)
77
end
8+
9+
job_ids.flatten
810
end
911

1012
def push_bulk!(items, &block)

spec/sidekiq_bulk_spec.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@ class BarJob < FooJob
4444
expect(FooJob).to have_enqueued_sidekiq_job(-6.1)
4545
expect(FooJob).to have_enqueued_sidekiq_job("a thing")
4646
end
47+
48+
it "returns the enqueued job ids" do
49+
allow(Sidekiq::Client).to receive(:push_bulk).and_return(["jid-1", "jid-2", "jid-3"])
50+
51+
job_ids = FooJob.public_send(method_name, [1, 2, 3])
52+
53+
expect(job_ids).to match_array(["jid-1", "jid-2", "jid-3"])
54+
end
4755
end
4856

4957
describe "#push_bulk" do

0 commit comments

Comments
 (0)