From 85a40db603c262671118668ee79d95a69093f914 Mon Sep 17 00:00:00 2001 From: Peng DU Date: Tue, 21 Jun 2016 16:04:44 +0200 Subject: [PATCH] price cache --- app/assets/javascripts/controllers/admin/pricing.coffee.erb | 2 +- app/assets/javascripts/services/price.coffee | 2 +- app/controllers/api/trainings_pricings_controller.rb | 2 +- app/views/api/prices/_price.json.jbuilder | 1 - app/views/api/prices/index.json.jbuilder | 2 +- .../api/trainings_pricings/_trainings_pricing.json.jbuilder | 3 --- 6 files changed, 4 insertions(+), 8 deletions(-) diff --git a/app/assets/javascripts/controllers/admin/pricing.coffee.erb b/app/assets/javascripts/controllers/admin/pricing.coffee.erb index c6b959c4a..99f6b9475 100644 --- a/app/assets/javascripts/controllers/admin/pricing.coffee.erb +++ b/app/assets/javascripts/controllers/admin/pricing.coffee.erb @@ -8,7 +8,7 @@ Application.Controllers.controller "EditPricingController", ["$scope", "$state", ### PUBLIC SCOPE ### ## List of machines prices (not considering any plan) - $scope.machinesPrices = machinesPricesPromise.prices + $scope.machinesPrices = machinesPricesPromise ## List of trainings pricing $scope.trainingsPricings = trainingsPricingsPromise diff --git a/app/assets/javascripts/services/price.coffee b/app/assets/javascripts/services/price.coffee index 66b8270fe..f836f943e 100644 --- a/app/assets/javascripts/services/price.coffee +++ b/app/assets/javascripts/services/price.coffee @@ -4,7 +4,7 @@ Application.Services.factory 'Price', ["$resource", ($resource)-> $resource "/api/prices/:id", {}, query: - isArray: false + isArray: true update: method: 'PUT' compute: diff --git a/app/controllers/api/trainings_pricings_controller.rb b/app/controllers/api/trainings_pricings_controller.rb index 367b1f72d..2db646e72 100644 --- a/app/controllers/api/trainings_pricings_controller.rb +++ b/app/controllers/api/trainings_pricings_controller.rb @@ -2,7 +2,7 @@ class API::TrainingsPricingsController < API::ApiController before_action :authenticate_user! def index - @trainings_pricings = TrainingsPricing.includes(:training) + @trainings_pricings = TrainingsPricing.all end def update diff --git a/app/views/api/prices/_price.json.jbuilder b/app/views/api/prices/_price.json.jbuilder index ca3aea1c4..19a0ffc06 100644 --- a/app/views/api/prices/_price.json.jbuilder +++ b/app/views/api/prices/_price.json.jbuilder @@ -1,3 +1,2 @@ json.extract! price, :id, :group_id, :plan_id, :priceable_type, :priceable_id json.amount price.amount / 100.0 -json.priceable_name price.priceable.name diff --git a/app/views/api/prices/index.json.jbuilder b/app/views/api/prices/index.json.jbuilder index 4f77c5ab7..8a03cbb34 100644 --- a/app/views/api/prices/index.json.jbuilder +++ b/app/views/api/prices/index.json.jbuilder @@ -1,3 +1,3 @@ json.cache! @prices do - json.prices @prices, partial: 'api/prices/price', as: :price + json.partial! 'api/prices/price', collection: @prices, as: :price end diff --git a/app/views/api/trainings_pricings/_trainings_pricing.json.jbuilder b/app/views/api/trainings_pricings/_trainings_pricing.json.jbuilder index 221217ac2..1d215bd50 100644 --- a/app/views/api/trainings_pricings/_trainings_pricing.json.jbuilder +++ b/app/views/api/trainings_pricings/_trainings_pricing.json.jbuilder @@ -1,5 +1,2 @@ json.extract! trainings_pricing, :id, :group_id, :training_id json.amount trainings_pricing.amount / 100.0 -json.training do - json.name trainings_pricing.training.name -end