Updated GabTrendsController, ShopController APIs to have logs and reorder returns

• Updated:
- GabTrendsController, ShopController APIs to have logs and reorder returns
This commit is contained in:
mgabdev
2020-07-08 18:35:42 -05:00
parent 2f2e1a13d0
commit 7548b1ea47
2 changed files with 22 additions and 9 deletions

View File

@@ -14,20 +14,25 @@ class Api::V1::ShopController < Api::BaseController
if body.nil? || body.empty?
Request.new(:get, "https://shop.dissenter.com/product/group/json").perform do |res|
Rails.logger.debug "ShopController dissenter products endpoint res code: #{res.code.to_s}"
if res.code == 200
body = res.body_with_limit
Redis.current.set("gabstore:featuredproducts", body)
Redis.current.expire("gabstore:featuredproducts", 15.minutes.seconds)
render json: body
else
body = nil
render json: nil
end
end
else
render json: body
end
render json: body
else
raise GabSocial::NotPermittedError
end
rescue HTTP::TimeoutError, HTTP::ConnectionError, OpenSSL::SSL::SSLError, HTTP::Error
Rails.logger.debug "Error fetching dissenter shop: #{type}"
render json: nil
end
end