mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
PERF: fixes multiple N+1 while loading threads (#22106)
This commit is contained in:
@@ -52,11 +52,17 @@ module Chat
|
|||||||
|
|
||||||
def fetch_threads(guardian:, channel:, **)
|
def fetch_threads(guardian:, channel:, **)
|
||||||
Chat::Thread
|
Chat::Thread
|
||||||
|
.strict_loading
|
||||||
.includes(
|
.includes(
|
||||||
:channel,
|
:channel,
|
||||||
:last_reply,
|
last_reply: [:uploads],
|
||||||
original_message_user: :user_status,
|
original_message_user: :user_status,
|
||||||
original_message: :chat_webhook_event,
|
original_message: [
|
||||||
|
:chat_webhook_event,
|
||||||
|
:chat_mentions,
|
||||||
|
:chat_channel,
|
||||||
|
user: :user_status,
|
||||||
|
],
|
||||||
)
|
)
|
||||||
.select("chat_threads.*, MAX(chat_messages.created_at) AS last_posted_at")
|
.select("chat_threads.*, MAX(chat_messages.created_at) AS last_posted_at")
|
||||||
.joins(
|
.joins(
|
||||||
|
|||||||
Reference in New Issue
Block a user