Optimize shared chats list to use column projection (#163) (#21614)

The GET /chats/shared endpoint was loading full Chat rows including
the entire conversation history JSON blob, only to discard it and
return SharedChatResponse (id, title, share_id, timestamps). Now
uses with_entities() to select only the 5 needed columns, avoiding
deserialization of potentially large chat JSON for every shared chat.
This commit is contained in:
Classic298
2026-02-19 15:50:03 -06:00
committed by GitHub
parent 27c76c677a
commit 35763a352c
2 changed files with 25 additions and 14 deletions
+7 -12
View File
@@ -887,18 +887,13 @@ async def get_shared_session_user_chat_list(
if direction:
filter["direction"] = direction
chat_list = [
SharedChatResponse(**chat.model_dump())
for chat in Chats.get_shared_chat_list_by_user_id(
user.id,
filter=filter,
skip=skip,
limit=limit,
db=db,
)
]
return chat_list
return Chats.get_shared_chat_list_by_user_id(
user.id,
filter=filter,
skip=skip,
limit=limit,
db=db,
)
############################