Tell Rubocop and devs about bulk insert

This commit is contained in:
Maikel Linke
2023-05-12 10:30:47 +10:00
parent b139087c5f
commit 636b365304

View File

@@ -108,10 +108,13 @@ class Exchange < ApplicationRecord
private
# An Order Cycle can have thousands of ExchangeVariants.
# It's a simple association without any callbacks on creation. So we can
# insert in bulk and improve the performance tenfold for large order cycles.
def clone_all_exchange_variants(exchange_id)
return unless variant_ids.any?
ExchangeVariant.insert_all(
ExchangeVariant.insert_all( # rubocop:disable Rails/SkipsModelValidations
variant_ids.map{ |variant_id| { variant_id: variant_id, exchange_id: exchange_id } }
)
end