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
|
def show
|
||||||
@post = Post.find(params[:id])
|
@post = Post.find(params[:id])
|
||||||
|
|
||||||
@comments = @post.comments
|
if request.format == Mime::Type.lookup("text/html")
|
||||||
@comments = @comments.includes(:creator)
|
@comments = @post.comments
|
||||||
@comments = @comments.includes(:votes) if CurrentUser.is_member?
|
@comments = @comments.includes(:creator)
|
||||||
@comments = @comments.visible(CurrentUser.user)
|
@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?
|
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 = @post.parent.present? ? @post.parent.children : Post.none
|
||||||
@sibling_posts = @sibling_posts.undeleted unless include_deleted
|
@sibling_posts = @sibling_posts.undeleted unless include_deleted
|
||||||
|
|
||||||
@child_posts = @post.children
|
@child_posts = @post.children
|
||||||
@child_posts = @child_posts.undeleted unless include_deleted
|
@child_posts = @child_posts.undeleted unless include_deleted
|
||||||
|
end
|
||||||
|
|
||||||
respond_with(@post) do |format|
|
respond_with(@post) do |format|
|
||||||
format.html.tooltip { render layout: false }
|
format.html.tooltip { render layout: false }
|
||||||
|
|||||||
Reference in New Issue
Block a user