Updated PopularLinksController

• Updated:
- PopularLinksController
This commit is contained in:
mgabdev 2020-11-09 14:02:44 -06:00
parent 0ac93cceec
commit 10219345f7

View File

@ -20,13 +20,17 @@ class Api::V1::PopularLinksController < Api::BaseController
def get_top_gab
# prod gab.com @gab account = 251
Status.where(account_id: '1').limit(2)
Status.where(account_id: '251').limit(2)
end
def get_videos
return []
end
def get_cards
body = Redis.current.get("popular_links:card_ids")
if body.nil? || body.empty?
statusIds = Status.where('statuses.created_at > ?', 24.hours.ago)
.joins(:status_stat)
.order('status_stats.favourites_count DESC')
@ -45,15 +49,17 @@ class Api::V1::PopularLinksController < Api::BaseController
.group('preview_cards.id')
.limit(10)
cards
card_ids = cards.map(&:id)
Redis.current.set("popular_links:card_ids", card_ids.join(','))
Redis.current.expire("popular_links:card_ids", 15.minutes.seconds)
return cards
else
cards = PreviewCard.where(id: body.split(','))
return cards
end
# if body.nil? || body.empty?
# Redis.current.set("gabtrends:feed", body)
# Redis.current.expire("gabtrends:feed", 1.hour.seconds)
# return cards
# else
# return cardIds
# end
end
end