posts/show: refactor parent/child notices.
* Convert notices from helpers to partials. * Eliminate PostSets::PostRelationship class in favor of post_sets/posts template. * Eliminate COUNT(*) queries when calculating the number of child posts. * Eliminate redundant parent load and parent exists queries.
This commit is contained in:
@@ -27,8 +27,11 @@ class PostsController < ApplicationController
|
||||
@comments = @comments.visible(CurrentUser.user)
|
||||
|
||||
include_deleted = @post.is_deleted? || (@post.parent_id.present? && @post.parent.is_deleted?) || CurrentUser.user.show_deleted_children?
|
||||
@parent_post_set = PostSets::PostRelationship.new(@post.parent_id, :include_deleted => include_deleted)
|
||||
@children_post_set = PostSets::PostRelationship.new(@post.id, :include_deleted => include_deleted)
|
||||
@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
|
||||
|
||||
respond_with(@post) do |format|
|
||||
format.html.tooltip { render layout: false }
|
||||
|
||||
Reference in New Issue
Block a user