Skip to content

A platform for community discussion. Free, open, simple.

FIX: Further optimize mentioning groups in chat messages (part 2) (#24185)

Andrei Prigorshneva32fce9e1da6
diff --git a/plugins/chat/lib/chat/parsed_mentions.rb b/plugins/chat/lib/chat/parsed_mentions.rb
index a246ef8f26f..cb66917071c 100644
--- a/plugins/chat/lib/chat/parsed_mentions.rb
+++ b/plugins/chat/lib/chat/parsed_mentions.rb
@@ -89,7 +89,7 @@ module Chat
private
def channel_members
- chat_users.where(
+ chat_users.includes(:user_chat_channel_memberships).where(
user_chat_channel_memberships: {
following: true,
chat_channel_id: @message.chat_channel.id,
@@ -98,13 +98,7 @@ module Chat
end
def chat_users
- User
- .includes(:user_chat_channel_memberships, :group_users)
- .distinct
- .joins("LEFT OUTER JOIN user_chat_channel_memberships uccm ON uccm.user_id = users.id")
- .joins(:user_option)
- .real
- .where(user_options: { chat_enabled: true })
+ User.distinct.joins(:user_option).real.where(user_options: { chat_enabled: true })
end
def mentionable_groups