2021-11-25 23:07:38 +11:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class Api::V1::Trends::LinksController < Api::BaseController
|
|
|
|
before_action :set_links
|
|
|
|
|
|
|
|
def index
|
|
|
|
render json: @links, each_serializer: REST::Trends::LinkSerializer
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def set_links
|
|
|
|
@links = begin
|
|
|
|
if Setting.trends
|
2022-02-25 10:34:14 +11:00
|
|
|
links_from_trends
|
2021-11-25 23:07:38 +11:00
|
|
|
else
|
|
|
|
[]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2022-02-25 10:34:14 +11:00
|
|
|
|
|
|
|
def links_from_trends
|
|
|
|
Trends.links.query.allowed.in_locale(content_locale).limit(limit_param(10))
|
|
|
|
end
|
2021-11-25 23:07:38 +11:00
|
|
|
end
|