docbrown/app/controllers/api/v0/comments_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

25 lines
703 B
Ruby

module Api
module V0
class CommentsController < 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
def index
article = Article.find(params[:a_id])
@comments = Comment.rooted_on(article, "Article").order(score: :desc)
end
def show
@comment = Comment.find(params[:id].to_i(26))
end
end
end
end