FIX: Remove N+1 queries in posts.json

This commit is contained in:
Kane York 2015-09-04 13:36:47 -07:00
parent 32e5016dbb
commit 27ee8bea95
1 changed files with 2 additions and 1 deletions

View File

@ -37,7 +37,8 @@ class PostsController < ApplicationController
.where('posts.id <= ?', last_post_id)
.where('posts.id > ?', last_post_id - 50)
.includes(topic: :category)
.includes(:user)
.includes(user: :primary_group)
.includes(:reply_to_user)
.limit(50)
# Remove posts the user doesn't have permission to see
# This isn't leaking any information we weren't already through the post ID numbers