Skip to content

Commit

Permalink
Include barrier.
Browse files Browse the repository at this point in the history
  • Loading branch information
tpendragon committed Oct 12, 2023
1 parent 669817c commit 8720694
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/services/card_image_loading_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ def import
end
end.flat_map(&:wait)
progress_bar.total = all_files.count
import_files(all_files)
import_files(all_files, barrier)
ensure
barrier.stop
end
end

def import_files(all_files)
def import_files(all_files, barrier)
Sync do
# Insert 10 batches at a time.
semaphore = Async::Semaphore.new(10)
semaphore = Async::Semaphore.new(10, parent: barrier)
# insert_all in batches of 1000
all_files.each_slice(1000).map do |slice|
semaphore.async do
Expand Down

0 comments on commit 8720694

Please sign in to comment.