diff options
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/api/reviews_controller.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/app/controllers/api/reviews_controller.rb b/app/controllers/api/reviews_controller.rb index 1f48362..52e7ec3 100644 --- a/app/controllers/api/reviews_controller.rb +++ b/app/controllers/api/reviews_controller.rb @@ -10,6 +10,12 @@ module Api render status: :not_found and return if @product.nil? + if params[:by].present? + render json: { posted: Reviews::HasUserAlreadyPostedReviewQuery.new(@product).review_posted?(params[:by]) }, + status: :ok + return + end + @reviews = @product.product_reviews.joins(:user_account).select('product_reviews.*', 'user_accounts.first_name as author_name') render json: serialized_collection.serializable_hash, status: :ok @@ -41,7 +47,7 @@ module Api end def serialized_collection - @serialized_collection ||= ProductReviewSerializer.new(@reviews) + @serialized_collection ||= ProductReviewSerializer.new(@reviews.page(params[:page])) end def serialized_object |