Remove n+1 query on Categories
This commit is contained in:
parent
ce78cb1ee4
commit
cca78f1031
|
@ -38,7 +38,7 @@ class Group < ActiveRecord::Base
|
||||||
|
|
||||||
def posts_for(guardian, before_post_id=nil)
|
def posts_for(guardian, before_post_id=nil)
|
||||||
user_ids = group_users.map {|gu| gu.user_id}
|
user_ids = group_users.map {|gu| gu.user_id}
|
||||||
result = Post.where(user_id: user_ids).includes(:user, :topic).references(:posts, :topics)
|
result = Post.where(user_id: user_ids).includes(:user, :topic, :topic => :category).references(:posts, :topics, :category)
|
||||||
.where('topics.archetype <> ?', Archetype.private_message)
|
.where('topics.archetype <> ?', Archetype.private_message)
|
||||||
.where(post_type: Post.types[:regular])
|
.where(post_type: Post.types[:regular])
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue