* Rubocop enabled style/alias * Enabled Style/ArrayJoin Cop * Enabled Style/Attr * Enabled Case Equality * Enabled CharacterLiteral * Enabled ColonMethodCall Cop * Enabled CommentAnnotation cop * Enabled PreferredHashMethods Cop * Enabled DoubleNegation Cop * Enabled EachWithObject Cop * Enabled EmptyLiteral Cop * Enabled EvenOdd Cop * Enabled IfWithSemicolon Cop * Enabled Lambda and LambdaCall Cop * Enabled LineEndConcatenation Cop * Enabled ModuleFunction Cop; * Enable NegatedIf and NegatedWhile Cop * Enabled NilComparison Cop * Enabled Not Cop * Enabled NumericLiterals Cop * Enabled OneLineConditional Cop * Enabled PercentLiteralDelimiters Cop * Excluded internal/users_controller from negated_if cop * Reverted the double negation change from github_issue_tag and github_issue.rb" * Enabled PerlBackrefs Cop * Changed Regexp.last_match(1) to Regexp.last_match(0) * Enabled proc cop * Enabled RaiseArgs Cop * Reverted Regexp.last_match(0) to Regexp.last_match(1) * Enabled SelfAssignment Cop * Enabled SingleLineMethods Cop * Enabled SpecialGlobalVars Cop * Enabled VariableInterpolation Cop * Enabled WhenThen Cop * Enabled WhileUntilModifier Cop * Enabled WordArray Cop * Enabled IfUnlessModifier Cop * Enabled GuardClause Cop
32 lines
945 B
Ruby
32 lines
945 B
Ruby
module Api
|
|
module V0
|
|
class PodcastEpisodesController < ApiController
|
|
# before_action :set_cache_control_headers, only: [:index, :show]
|
|
caches_action :index,
|
|
cache_path: proc { |c| c.params.permit! },
|
|
expires_in: 10.minutes
|
|
respond_to :json
|
|
|
|
caches_action :show,
|
|
cache_path: proc { |c| c.params.permit! },
|
|
expires_in: 10.minutes
|
|
respond_to :json
|
|
|
|
before_action :cors_preflight_check
|
|
after_action :cors_set_access_control_headers
|
|
|
|
def index
|
|
@page = params[:page]
|
|
if params[:username]
|
|
@podcast = Podcast.find_by_slug(params[:username]) || not_found
|
|
@podcast_episodes = @podcast.
|
|
podcast_episodes.order("published_at desc").
|
|
page(@page).
|
|
per(30)
|
|
else
|
|
@podcast_episodes = PodcastEpisode.order("published_at desc").page(@page).per(30)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|