posts: eager load uploader and media asset on posts show page.

Eliminate a couple SQL queries by loading the uploader and media asset
in the same query as the post.
This commit is contained in:
evazion
2022-04-18 00:08:29 -05:00
parent 436f3eaf5d
commit 5050ca527d

View File

@@ -27,7 +27,7 @@ class PostsController < ApplicationController
end
def show
@post = authorize Post.find(params[:id])
@post = authorize Post.eager_load(:uploader, :media_asset).find(params[:id])
if request.format.html?
include_deleted = @post.is_deleted? || (@post.parent_id.present? && @post.parent.is_deleted?) || CurrentUser.user.show_deleted_children?