You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
616 B

  1. # frozen_string_literal: true
  2. class Api::V1::Trends::StatusesController < Api::BaseController
  3. before_action :set_statuses
  4. def index
  5. render json: @statuses, each_serializer: REST::StatusSerializer
  6. end
  7. private
  8. def set_statuses
  9. @statuses = begin
  10. if Setting.trends
  11. cache_collection(statuses_from_trends, Status)
  12. else
  13. []
  14. end
  15. end
  16. end
  17. def statuses_from_trends
  18. scope = Trends.statuses.query.allowed.in_locale(content_locale)
  19. scope = scope.filtered_for(current_account) if user_signed_in?
  20. scope.limit(limit_param(DEFAULT_STATUSES_LIMIT))
  21. end
  22. end