Merge pull request #5145 from luisramos0/inv_perf

Performance improvements to Inventory page
This commit is contained in:
Luis Ramos
2020-04-09 13:56:33 +01:00
committed by GitHub
2 changed files with 7 additions and 3 deletions

View File

@@ -73,8 +73,10 @@ module Admin
end
def collection
@variant_overrides = VariantOverride.includes(:variant).for_hubs(params[:hub_id] || @hubs)
@variant_overrides.select { |vo| vo.variant.present? }
@variant_overrides = VariantOverride.
includes(variant: :product).
for_hubs(params[:hub_id] || @hubs).
select { |vo| vo.variant.present? }
end
def collection_actions

View File

@@ -15,8 +15,10 @@ class VariantOverrideSet < ModelSet
tag_list.empty?
end
# Override of ModelSet method to allow us to check presence of a tag_list (which is not an attribute)
# This method will delete VariantOverrides that have no values (see deletable? above)
# If the user sets all values to nil in the UI the VO will be deleted from the DB
def collection_to_delete
# Override of ModelSet method to allow us to check presence of a tag_list (which is not an attribute)
deleted = []
collection.delete_if { |e| deleted << e if @delete_if.andand.call(e.attributes, e.tag_list) }
deleted