Merge pull request #5238 from Matt-Yorkley/moar-performance

Improve Pain Points
This commit is contained in:
Pau Pérez Fabregat
2020-04-29 16:36:15 +02:00
committed by GitHub
4 changed files with 21 additions and 5 deletions

View File

@@ -1,9 +1,13 @@
module Admin
class EnterpriseRelationshipsController < ResourceController
def index
@my_enterprises = Enterprise.managed_by(spree_current_user).by_name
@all_enterprises = Enterprise.by_name
@enterprise_relationships = EnterpriseRelationship.by_name.involving_enterprises @my_enterprises
@my_enterprises = Enterprise.
includes(:shipping_methods, :payment_methods).
managed_by(spree_current_user).by_name
@all_enterprises = Enterprise.includes(:shipping_methods, :payment_methods).by_name
@enterprise_relationships = EnterpriseRelationship.
includes(:parent, :child).
by_name.involving_enterprises @my_enterprises
end
def create

View File

@@ -47,7 +47,7 @@ module InjectionHelper
enterprises_and_relatives = current_distributor.
relatives_including_self.
activated.
includes(address: [:state, :country]).
includes(:properties, address: [:state, :country], supplied_products: :properties).
all
inject_json_ams "enterprises",

View File

@@ -263,7 +263,11 @@ Spree::Order.class_eval do
end
def line_item_variants
line_items.map(&:variant)
if line_items.loaded?
line_items.map(&:variant)
else
line_items.includes(:variant).map(&:variant)
end
end
# Show already bought line items of this order cycle

View File

@@ -1,4 +1,12 @@
class Api::Admin::BasicEnterpriseSerializer < ActiveModel::Serializer
attributes :name, :id, :is_primary_producer, :is_distributor, :sells, :category,
:payment_method_ids, :shipping_method_ids, :producer_profile_only, :permalink
def payment_method_ids
object.payment_methods.map(&:id)
end
def shipping_method_ids
object.shipping_methods.map(&:id)
end
end