fix(conversations): prefetch support_identity_snapshot

conversation_payload для support-диалогов дёргает support_identity_snapshot FK
на каждую строку списка inbox → N+1. Добавлен select_related в
conversations_for_organization. Для sales (snapshot=null) безвредно.
This commit is contained in:
Andrey committed 2026-07-09 16:06:47 +03:00
1 parent 94e2d1a19c
commit fbf4919bee
1 file changed
+8 -1
@@ -6,7 +6,14 @@ from hub_platform.conversations.models import Conversation
def conversations_for_organization(organization_id: int) -> QuerySet[Conversation]:
return (
Conversation.objects.filter(organization_id=organization_id)
.select_related("channel", "channel__product", "contact", "connection", "assigned_operator")
.select_related(
"channel",
"channel__product",
"contact",
"connection",
"assigned_operator",
"support_identity_snapshot",
)
.order_by("-last_activity_at")
)