From 58a167a92ac08d4466533332fd9f08b932643d9a Mon Sep 17 00:00:00 2001 From: Vincent Pochet Date: Tue, 28 May 2024 16:56:21 +0200 Subject: [PATCH] misc: rollback parallel as it raises DB connection errors --- app/services/invoices/customer_usage_service.rb | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/services/invoices/customer_usage_service.rb b/app/services/invoices/customer_usage_service.rb index 0219b80e12f..20433a0b6dd 100644 --- a/app/services/invoices/customer_usage_service.rb +++ b/app/services/invoices/customer_usage_service.rb @@ -66,11 +66,14 @@ def add_charge_fees .includes(:taxes, billable_metric: :organization, filters: {values: :billable_metric_filter}) .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| - ActiveRecord::Base.connection_pool.with_connection do - charge_usage(charge) - end + # TODO: fix issue with db connection pool + # invoice.fees = Parallel.flat_map(query.all, in_threads: ENV['LAGO_PARALLEL_THREADS_COUNT']&.to_i || 1) do |charge| + # ActiveRecord::Base.connection_pool.with_connection do + query.each do |charge| + invoice.fees << charge_usage(charge) end + # end + # end end def charge_usage(charge)