mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-11 23:17:48 +00:00
Tell Rubocop and devs about bulk insert
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user