Added new check for GabTrendsController, ShopController for empty

• Added:
- new check for GabTrendsController, ShopController for empty
This commit is contained in:
mgabdev 2020-07-08 17:41:48 -05:00
parent b33e33362c
commit 22c0957752
2 changed files with 4 additions and 4 deletions

View File

@ -10,7 +10,7 @@ class Api::V1::GabTrendsController < Api::BaseController
if type == 'feed' if type == 'feed'
body = Redis.current.get("gabtrends:feed") body = Redis.current.get("gabtrends:feed")
if body.nil? if body.nil? || body.empty?
Request.new(:get, "https://trends.gab.com/trend-feed/json").perform do |res| Request.new(:get, "https://trends.gab.com/trend-feed/json").perform do |res|
if res.code == 200 if res.code == 200
body = res.body_with_limit body = res.body_with_limit
@ -26,12 +26,12 @@ class Api::V1::GabTrendsController < Api::BaseController
elsif type == 'partner' elsif type == 'partner'
body = Redis.current.get("gabtrends:partner") body = Redis.current.get("gabtrends:partner")
if body.nil? if body.nil? || body.empty?
Request.new(:get, "https://trends.gab.com/partner").perform do |res| Request.new(:get, "https://trends.gab.com/partner").perform do |res|
if res.code == 200 if res.code == 200
body = res.body_with_limit body = res.body_with_limit
Redis.current.set("gabtrends:partner", body) Redis.current.set("gabtrends:partner", body)
Redis.current.expire("gabtrends:partner", 1.minute.seconds) Redis.current.expire("gabtrends:partner", 1.minute.seconds)
else else
body = nil body = nil
end end

View File

@ -12,7 +12,7 @@ class Api::V1::ShopController < Api::BaseController
if type == 'featured_products' if type == 'featured_products'
body = Redis.current.get("gabstore:featuredproducts") body = Redis.current.get("gabstore:featuredproducts")
if body.nil? if body.nil? || body.empty?
Request.new(:get, "https://shop.dissenter.com/product/group/json").perform do |res| Request.new(:get, "https://shop.dissenter.com/product/group/json").perform do |res|
if res.code == 200 if res.code == 200
body = res.body_with_limit body = res.body_with_limit