Commit 75f4af89 authored by BrokenEagle's avatar BrokenEagle

Don't do unnecessary processing on posts when using the API

parent f7495f5e
......@@ -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)
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
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
@child_posts = @post.children
@child_posts = @child_posts.undeleted unless include_deleted
end
respond_with(@post) do |format|
format.html.tooltip { render layout: false }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment