mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Improve performance for Group.posts_for
(#6588)
This commit is contained in:
parent
cee1f5b2c1
commit
c3c9299c44
@ -193,10 +193,9 @@ class Group < ActiveRecord::Base
|
||||
|
||||
def posts_for(guardian, opts = nil)
|
||||
opts ||= {}
|
||||
user_ids = group_users.map { |gu| gu.user_id }
|
||||
result = Post.includes(:user, :topic, topic: :category)
|
||||
result = Post.includes(:topic, user: :groups, topic: :category)
|
||||
.references(:posts, :topics, :category)
|
||||
.where(user_id: user_ids)
|
||||
.where(groups: { id: id })
|
||||
.where('topics.archetype <> ?', Archetype.private_message)
|
||||
.where('topics.visible')
|
||||
.where(post_type: Post.types[:regular])
|
||||
|
Loading…
Reference in New Issue
Block a user