mirror of
https://github.com/discourse/discourse.git
synced 2025-06-18 05:17:23 +08:00
Revert "PERF: Prefer joins over subquery for User#private_posts_for_user
."
This reverts commit 05b43e5ae45fed10742de0829e579880098adcf7.
This commit is contained in:
@ -80,10 +80,7 @@ class Post < ActiveRecord::Base
|
|||||||
register_custom_field_type(MISSING_UPLOADS_IGNORED, :boolean)
|
register_custom_field_type(MISSING_UPLOADS_IGNORED, :boolean)
|
||||||
|
|
||||||
scope :private_posts_for_user, ->(user) {
|
scope :private_posts_for_user, ->(user) {
|
||||||
joins("LEFT JOIN topic_allowed_users ON topic_allowed_users.topic_id = posts.topic_id AND topic_allowed_users.user_id = #{user.id.to_i}")
|
where("posts.topic_id IN (#{Topic::PRIVATE_MESSAGES_SQL})", user_id: user.id)
|
||||||
.joins("LEFT JOIN group_users ON group_users.user_id = #{user.id.to_i}")
|
|
||||||
.joins("LEFT JOIN topic_allowed_groups ON topic_allowed_groups.topic_id = posts.topic_id AND topic_allowed_groups.group_id = group_users.group_id")
|
|
||||||
.where("topic_allowed_users.topic_id IS NOT NULL OR topic_allowed_groups.topic_id IS NOT NULL")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
scope :by_newest, -> { order('created_at DESC, id DESC') }
|
scope :by_newest, -> { order('created_at DESC, id DESC') }
|
||||||
|
Reference in New Issue
Block a user