mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-04-08 07:46:59 +00:00
Create variant links through Rails association
This allows us to delay saving to the db, reducing overall queries.
This commit is contained in:
@@ -56,10 +56,10 @@ module Spree
|
||||
target_variant: [mapped_variants.keys])
|
||||
# Link the new variants
|
||||
variant_links.find_each do |variant_link|
|
||||
VariantLink.create(
|
||||
source_variant: mapped_variants[variant_link.source_variant],
|
||||
target_variant: mapped_variants[variant_link.target_variant]
|
||||
)
|
||||
source_variant = mapped_variants[variant_link.source_variant]
|
||||
target_variant = mapped_variants[variant_link.target_variant]
|
||||
|
||||
target_variant.variant_links_as_target.new(source_variant:)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -101,85 +101,42 @@ RSpec.describe Spree::Core::ProductDuplicator do
|
||||
"VariantLink Load",
|
||||
"Spree::Variant Load",
|
||||
"Spree::Variant Load",
|
||||
"TRANSACTION",
|
||||
"Spree::ShippingCategory Load",
|
||||
"Spree::Product Load",
|
||||
"Spree::Taxon Load",
|
||||
"Enterprise Load",
|
||||
"Spree::Variant Create",
|
||||
"Spree::Price Create",
|
||||
"Spree::StockItem Exists?",
|
||||
"Spree::StockItem Exists?",
|
||||
"Spree::StockItem Create",
|
||||
"ActsAsTaggableOn::Tagging Load",
|
||||
"Spree::Variant Update",
|
||||
"Spree::ShippingCategory Load",
|
||||
"Spree::Product Load",
|
||||
"Spree::Taxon Load",
|
||||
"Enterprise Load",
|
||||
"Spree::Variant Create",
|
||||
"Spree::Price Create",
|
||||
"Spree::StockItem Exists?",
|
||||
"Spree::StockItem Exists?",
|
||||
"Spree::StockItem Create",
|
||||
"ActsAsTaggableOn::Tagging Load",
|
||||
"Spree::Variant Update",
|
||||
"VariantLink Create",
|
||||
"Spree::Product Update",
|
||||
"Spree::Variant Exists?",
|
||||
"Spree::Variant Load",
|
||||
"Enterprise Load",
|
||||
"Enterprise Update",
|
||||
"Enterprise Update All",
|
||||
"Spree::Taxon Update",
|
||||
"Enterprise Update",
|
||||
"Enterprise Update All",
|
||||
"TRANSACTION",
|
||||
"Spree::Variant Load",
|
||||
"Spree::Variant Load",
|
||||
"TRANSACTION",
|
||||
"Spree::ShippingCategory Load",
|
||||
"Spree::Product Load",
|
||||
"Spree::Taxon Load",
|
||||
"Enterprise Load",
|
||||
"Spree::Variant Create",
|
||||
"Spree::Price Create",
|
||||
"Spree::StockItem Exists?",
|
||||
"Spree::StockItem Exists?",
|
||||
"Spree::StockItem Create",
|
||||
"ActsAsTaggableOn::Tagging Load",
|
||||
"Spree::Variant Update",
|
||||
"VariantLink Create",
|
||||
"Spree::Product Update",
|
||||
"Spree::Variant Exists?",
|
||||
"Spree::Variant Load",
|
||||
"Spree::ShippingCategory Load",
|
||||
"Spree::Taxon Load",
|
||||
"Enterprise Load",
|
||||
"Spree::ShippingCategory Load",
|
||||
"Spree::Taxon Load",
|
||||
"Enterprise Load",
|
||||
"Enterprise Update",
|
||||
"Enterprise Update All",
|
||||
"Spree::Taxon Update",
|
||||
"Enterprise Update",
|
||||
"Enterprise Update All",
|
||||
"TRANSACTION",
|
||||
"TRANSACTION",
|
||||
"Spree::Product Create",
|
||||
"Spree::Variant Update",
|
||||
"Spree::StockItem Load",
|
||||
"Spree::Variant Create",
|
||||
"Spree::Price Create",
|
||||
"Spree::StockItem Exists?",
|
||||
"Spree::Product Load",
|
||||
"Spree::Variant Update",
|
||||
"Spree::StockItem Load",
|
||||
"Spree::StockItem Exists?",
|
||||
"Spree::Product Load",
|
||||
"Spree::StockItem Create",
|
||||
"ActsAsTaggableOn::Tagging Load",
|
||||
"Spree::Variant Update",
|
||||
"Spree::StockItem Load",
|
||||
"Spree::Variant Create",
|
||||
"Spree::Price Create",
|
||||
"VariantLink Create",
|
||||
"Spree::StockItem Exists?",
|
||||
"Spree::Product Load",
|
||||
"Spree::Product Update",
|
||||
"Spree::Variant Exists?",
|
||||
"Spree::Variant Load",
|
||||
"Enterprise Load",
|
||||
"Enterprise Update",
|
||||
"Enterprise Update All",
|
||||
"Spree::StockItem Exists?",
|
||||
"Spree::StockItem Create",
|
||||
"ActsAsTaggableOn::Tagging Load",
|
||||
"Spree::Variant Update",
|
||||
"Spree::Variant Create",
|
||||
"Spree::Price Create",
|
||||
"VariantLink Create",
|
||||
"Spree::StockItem Exists?",
|
||||
"Spree::StockItem Exists?",
|
||||
"Spree::StockItem Create",
|
||||
"ActsAsTaggableOn::Tagging Load",
|
||||
"Spree::Variant Update",
|
||||
"Spree::Product Update",
|
||||
"Enterprise Update",
|
||||
"Enterprise Update All",
|
||||
|
||||
Reference in New Issue
Block a user