Remove is_master and not_master scopes

This commit is contained in:
Matt-Yorkley
2023-06-05 12:50:40 +01:00
parent 0703bb4583
commit 1daab8994d
13 changed files with 9 additions and 19 deletions

View File

@@ -181,7 +181,6 @@ module Spree
joins(:product).
where('spree_products.supplier_id IN (?)', editable_enterprises.collect(&:id)).
where('spree_variants.import_date IS NOT NULL').
where(spree_variants: { is_master: false }).
where(spree_variants: { deleted_at: nil }).
order('spree_variants.import_date DESC')
end

View File

@@ -5,11 +5,7 @@ module Spree
module ImagesHelper
def options_text_for(image)
if image.viewable.is_a?(Spree::Variant)
if image.viewable.is_master?
I18n.t(:all)
else
image.viewable.options_text
end
image.viewable.options_text
else
I18n.t(:all)
end

View File

@@ -55,7 +55,6 @@ module ProductImport
VariantOverride.for_hubs([enterprise_id]).count
else
Spree::Variant.
not_master.
joins(:product).
where('spree_products.supplier_id IN (?)', enterprise_id).
count

View File

@@ -43,9 +43,8 @@ module Spree
has_many :properties, through: :product_properties
has_many :classifications, dependent: :delete_all
has_many :taxons, through: :classifications
has_many :variants, -> {
where(is_master: false).order("spree_variants.position ASC")
}, class_name: 'Spree::Variant', dependent: :destroy
has_many :variants, -> { order("spree_variants.position ASC") }, class_name: 'Spree::Variant',
dependent: :destroy
has_many :prices, -> {
order('spree_variants.position, spree_variants.id, currency')

View File

@@ -88,7 +88,6 @@ module Spree
scope :with_order_cycles_inner, -> { joins(exchanges: :order_cycle) }
scope :not_master, -> { where(is_master: false) }
scope :in_order_cycle, lambda { |order_cycle|
with_order_cycles_inner.
merge(Exchange.outgoing).

View File

@@ -18,7 +18,6 @@ class ExchangeProductsRenderer
def exchange_variants(incoming, enterprise)
variants_relation = Spree::Variant.
not_master.
where(product_id: exchange_products(incoming, enterprise).select(&:id))
filter_visible(variants_relation)

View File

@@ -97,7 +97,7 @@ class ProductsRenderer
end
def variants_for_shop_by_id
index_by_product_id variants_for_shop.reject(&:is_master)
index_by_product_id variants_for_shop
end
def index_by_product_id(variants)

View File

@@ -24,7 +24,7 @@ module Catalog
.joins(:product)
.where(
spree_products: { supplier_id: enterprise_ids },
spree_variants: { is_master: false, deleted_at: nil }
spree_variants: { deleted_at: nil }
)
return relation if excluded_items_ids.blank?

View File

@@ -9,7 +9,7 @@ class VariantFetcher
end
def scope
Spree::Variant.not_master.
Spree::Variant.
joins(:product).
where(spree_products: { supplier: @enterprise })
end

View File

@@ -16,7 +16,7 @@ module OrderManagement
variant_conditions << exchange_variant_ids
end
Spree::Variant.joins(:product).where(is_master: false).where(*variant_conditions)
Spree::Variant.joins(:product).where(*variant_conditions)
end
def self.in_open_and_upcoming_order_cycles?(distributor, schedule, variant)

View File

@@ -33,7 +33,7 @@ module OpenFoodNetwork
end
def query_scope
Spree::Variant.where(is_master: false).
Spree::Variant.
ransack(search_params.merge(m: 'or')).
result.
order("spree_products.name, display_name, display_as, spree_products.variant_unit_name").

View File

@@ -33,7 +33,6 @@ module Reporting
def child_variants
Spree::Variant.
where(is_master: false).
joins(:product).
merge(visible_products).
order('spree_products.name')

View File

@@ -42,7 +42,7 @@ describe Api::V0::VariantsController, type: :controller do
# Regression test for spree#2141
context "a deleted variant" do
before do
expect(Spree::Variant.not_master.count).to eq 7
expect(Spree::Variant.count).to eq 7
variant.update_column(:deleted_at, Time.zone.now)
end