From 2e1dd8a99f99176ccb7c0ee26b4627482b98b4d0 Mon Sep 17 00:00:00 2001 From: Richard Hallett Date: Wed, 1 Feb 2023 15:49:45 +0100 Subject: [PATCH] Add some optional batch_size to rake import --- lib/tasks/client.rake | 4 +++- lib/tasks/prefix.rake | 4 +++- lib/tasks/provider.rake | 4 +++- lib/tasks/provider_prefix.rake | 4 +++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/tasks/client.rake b/lib/tasks/client.rake index 153ddf4d5..0bbceee1b 100644 --- a/lib/tasks/client.rake +++ b/lib/tasks/client.rake @@ -53,7 +53,9 @@ namespace :client do desc "Import all clients" task import: :environment do - Client.import(index: Client.inactive_index) + batch_size = ENV["BATCH_SIZE"].nil? ? 10 : ENV["BATCH_SIZE"].to_i + + Client.import(index: Client.inactive_index, batch_size: batch_size) end desc "Delete from index by query" diff --git a/lib/tasks/prefix.rake b/lib/tasks/prefix.rake index 1d763e606..d3f209142 100644 --- a/lib/tasks/prefix.rake +++ b/lib/tasks/prefix.rake @@ -43,7 +43,9 @@ namespace :prefix do desc "Import all prefixes" task import: :environment do - Prefix.import(index: ENV["INDEX"] || Prefix.inactive_index, batch_size: (ENV["BATCH_SIZE"] || 100).to_i) + batch_size = ENV["BATCH_SIZE"].nil? ? 100 : ENV["BATCH_SIZE"].to_i + + Prefix.import(index: ENV["INDEX"] || Prefix.inactive_index, batch_size: batch_size) end desc "Create alias for prefixes" diff --git a/lib/tasks/provider.rake b/lib/tasks/provider.rake index d4f155366..c639d6b61 100644 --- a/lib/tasks/provider.rake +++ b/lib/tasks/provider.rake @@ -53,7 +53,9 @@ namespace :provider do desc "Import all providers" task import: :environment do - Provider.import(index: Provider.inactive_index) + batch_size = ENV["BATCH_SIZE"].nil? ? 10 : ENV["BATCH_SIZE"].to_i + + Provider.import(index: Provider.inactive_index, batch_size: batch_size) end desc "Export all providers to Salesforce" diff --git a/lib/tasks/provider_prefix.rake b/lib/tasks/provider_prefix.rake index 201a2bcec..7820a962a 100644 --- a/lib/tasks/provider_prefix.rake +++ b/lib/tasks/provider_prefix.rake @@ -43,7 +43,9 @@ namespace :provider_prefix do desc "Import all provider_prefixes" task import: :environment do - ProviderPrefix.import(index: ENV["INDEX"] || ProviderPrefix.inactive_index, batch_size: (ENV["BATCH_SIZE"] || 100).to_i) + batch_size = ENV["BATCH_SIZE"].nil? ? 100 : ENV["BATCH_SIZE"].to_i + + ProviderPrefix.import(index: ENV["INDEX"] || ProviderPrefix.inactive_index, batch_size: batch_size) end desc "Create alias for provider_prefixes"