updates based on F5 testing

This commit is contained in:
2020-03-06 08:35:12 -05:00
parent 8288595b3f
commit f1ef618dae
18 changed files with 66 additions and 32 deletions
@@ -4,11 +4,12 @@ module Suppliers
@employee_shifts = EmployeeShift.for_supplier(current_supplier, relevant_from: 1.week.ago)
#@employee_shifts.include_relations(:employee, :supplier)
# Only select shifts from currently linked and employees
@employee_shifts.select! do |shift|
return false unless current_supplier.employee_ids.include?(shift.employee.try(:id))
shift.employee.enrich_with_settings current_supplier.settings_for(shift.employee)
true
end
#@employee_shifts.select! do |shift|
# return false unless current_supplier.employee_ids.include?(shift.employee.try(:id))
# shift.employee.enrich_with_settings current_supplier.settings_for(shift.employee)
# true
#end
#@employee_shifts.each { |shift| shift.employee.enrich_with_settings current_supplier.settings_for(shift.employee)
render json: @employee_shifts
end
def create
@@ -8,6 +8,7 @@ module Suppliers
# GET /employees.json
def index
@employees = current_supplier.employees
@employees.each { |employee| employee.enrich_with_settings current_supplier.settings_for(employee) }
render json: @employees
end
+14 -2
View File
@@ -15,8 +15,20 @@ module Users
#EMBER
def current
@list = current_user.active_list
params[:id] = @list.try(:id) # serializer determines collection or not based on the presence of this
show
render json: {}, status: :not_found and return unless @list.present? && Array.wrap(@list.user_ids).include?(current_user.id)
include_config = %w[
supplier
supplier.product_categories
supplier.product_categories.products
supplier.product_categories.products.product_variants
join_requests
join_requests.user
table
orders
orders.product_orders
]
include_config << 'users' if @list.user_ids.size > 1
render json: @list, include: include_config, serializer: Users::ListSerializer, is_collection: false
end
def table
+10 -4
View File
@@ -4,10 +4,16 @@ module Users
def show
@supplier = Supplier.find(params[:id])
render json: {}, status: :not_found and return unless @supplier.present?
render json: @supplier, include: %w[
product_categories
product_categories.products
product_categories.products.product_variants
render json: @supplier
end
def product_categories
@supplier = Supplier.find(params[:id])
render json: {}, status: :not_found and return unless @supplier.present?
@supplier.product_categories.include_relations products: :product_variants
render json: @supplier.product_categories, serializer: Users::ProductCategorySerializer, is_collection: true, include: %w[
products
products.product_variants
]
end
end
+12 -11
View File
@@ -3,19 +3,19 @@ module Users
respond_to :json
def show
@table = Table.find(params[:id])
render json: JSONAPI::Serializer.serialize(@table, serializer: Users::TableSerializer)
render json: @table, include: ['supplier']
end
def supplier
table = Table.find(params[:id])
supplier = table.supplier
supplier.product_categories.include_relations(products: :product_variants)
render json: supplier, include: %w[
product_categories
product_categories.products
product_categories.products.product_variants
]
end
#def supplier
# table = Table.find(params[:id])
# supplier = table.supplier
# supplier.product_categories.include_relations(products: :product_variants)
# render json: supplier, include: %w[
# product_categories
# product_categories.products
# product_categories.products.product_variants
# ]
#end
# POST /tables/:id/needs_help.json
def needs_help
@@ -67,6 +67,7 @@ module Users
res = {}
res[:active_list_present] = true if active_list.present?
res[:occupied] = table.occupied?
res[:active] = table.active?
res[:reserved] = table.reserved?
res[:supplier_closed] = table.supplier.closed?
res[:no_product_orders] = true unless product_orders = new_order_product_orders.presence