Don't do unnecessary processing on posts when using the API
This commit is contained in:
@@ -21,17 +21,19 @@ class PostsController < ApplicationController
|
||||
def show
|
||||
@post = Post.find(params[:id])
|
||||
|
||||
@comments = @post.comments
|
||||
@comments = @comments.includes(:creator)
|
||||
@comments = @comments.includes(:votes) if CurrentUser.is_member?
|
||||
@comments = @comments.visible(CurrentUser.user)
|
||||
if request.format == Mime::Type.lookup("text/html")
|
||||
@comments = @post.comments
|
||||
@comments = @comments.includes(:creator)
|
||||
@comments = @comments.includes(:votes) if CurrentUser.is_member?
|
||||
@comments = @comments.visible(CurrentUser.user)
|
||||
|
||||
include_deleted = @post.is_deleted? || (@post.parent_id.present? && @post.parent.is_deleted?) || CurrentUser.user.show_deleted_children?
|
||||
@sibling_posts = @post.parent.present? ? @post.parent.children : Post.none
|
||||
@sibling_posts = @sibling_posts.undeleted unless include_deleted
|
||||
include_deleted = @post.is_deleted? || (@post.parent_id.present? && @post.parent.is_deleted?) || CurrentUser.user.show_deleted_children?
|
||||
@sibling_posts = @post.parent.present? ? @post.parent.children : Post.none
|
||||
@sibling_posts = @sibling_posts.undeleted unless include_deleted
|
||||
|
||||
@child_posts = @post.children
|
||||
@child_posts = @child_posts.undeleted unless include_deleted
|
||||
@child_posts = @post.children
|
||||
@child_posts = @child_posts.undeleted unless include_deleted
|
||||
end
|
||||
|
||||
respond_with(@post) do |format|
|
||||
format.html.tooltip { render layout: false }
|
||||
|
||||
Reference in New Issue
Block a user