Skip to content

Commit

Permalink
fix(current-usage): Manage connection pools with parallel threads
Browse files Browse the repository at this point in the history
  • Loading branch information
vincent-pochet committed May 28, 2024
1 parent f957323 commit 49dbef5
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/services/invoices/customer_usage_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ def add_charge_fees
.order(Arel.sql('lower(unaccent(billable_metrics.name)) ASC'))

invoice.fees = Parallel.flat_map(query.all, in_threads: ENV['LAGO_PARALLEL_THREADS_COUNT']&.to_i || 1) do |charge|
charge_usage(charge)
ActiveRecord::Base.connection_pool.with_connection do
charge_usage(charge)
end
end
end

Expand Down

0 comments on commit 49dbef5

Please sign in to comment.