Skip to content

Commit 661af6c

Browse files
committed
perf: project only Chat.id in delete_shared_chats_by_user_id
1 parent 4b9b23b commit 661af6c

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

backend/open_webui/models/chats.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1461,8 +1461,8 @@ def move_chats_by_user_id_and_folder_id(
14611461
def delete_shared_chats_by_user_id(self, user_id: str, db: Optional[Session] = None) -> bool:
14621462
try:
14631463
with get_db_context(db) as db:
1464-
chats_by_user = db.query(Chat).filter_by(user_id=user_id).all()
1465-
shared_chat_ids = [f'shared-{chat.id}' for chat in chats_by_user]
1464+
id_rows = db.query(Chat.id).filter_by(user_id=user_id).all()
1465+
shared_chat_ids = [f'shared-{row[0]}' for row in id_rows]
14661466

14671467
# Use subquery to delete chat_messages for shared chats
14681468
shared_id_subq = db.query(Chat.id).filter(Chat.user_id.in_(shared_chat_ids)).subquery()

0 commit comments

Comments
 (0)