docbrown/app/controllers/podcast_episodes_controller.rb
rhymes 6a626e819d Refactor: fix issues raised by bullet (#2965)
* Preload organization, not user

* Preload users only when needed

* Pre-load podcasts for podcast episodes in API

* Avoid eager loading error by loading rating votes separately

* Preload associations for moderation

* Preload user comments in trees

* Preload organization for non org dashboard and cleanup queries

* Optimize ArticleSuggester to only load N articles at need

* Remove eager loading and pass variables to partials for easier debug

* Reorganize tags validation code and ignore actsastaggableon eager loading issues

* Remove unused eager loading and bring up comments relation

* Preload podcasts when loading podcast episodes

* Fix views specs

* Make sure ArticleSuggester never returns duplicates

* Remove commented code

* Re-trigger build

* Move suggested articles back to view to respect fragment caching
2019-05-28 17:32:53 -04:00

29 lines
1 KiB
Ruby

class PodcastEpisodesController < ApplicationController
# No authorization required for entirely public controller
before_action :set_cache_control_headers, only: [:index]
def index
@podcast_index = true
@podcasts = Podcast.order("title asc")
@podcast_episodes = PodcastEpisode.includes(:podcast).order("published_at desc").first(20)
if params[:q].blank?
set_surrogate_key_header("podcast_episodes_all " + params[:q].to_s,
@podcast_episodes.map { |e| e["record_key"] })
end
@featured_story = Article.new
@article_index = true
@list_of = "podcast-episodes"
render template: "podcast_episodes/index"
end
private
def podcast_episode_params
params.require(:podcast_episode).permit(:title,
:body,
:image,
:social_image,
:remote_social_image_url,
:quote)
end
end