mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Merge pull request #5238 from Matt-Yorkley/moar-performance
Improve Pain Points
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user