Skip to content

Commit 2a74011

Browse files
Algorithm5838github-actions[bot]
authored andcommitted
perf: project only Chat.id in delete_shared_chats_by_user_id
1 parent 30e9598 commit 2a74011

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
@@ -1470,8 +1470,8 @@ def move_chats_by_user_id_and_folder_id(
14701470
def delete_shared_chats_by_user_id(self, user_id: str, db: Optional[Session] = None) -> bool:
14711471
try:
14721472
with get_db_context(db) as db:
1473-
chats_by_user = db.query(Chat).filter_by(user_id=user_id).all()
1474-
shared_chat_ids = [f'shared-{chat.id}' for chat in chats_by_user]
1473+
id_rows = db.query(Chat.id).filter_by(user_id=user_id).all()
1474+
shared_chat_ids = [f'shared-{row[0]}' for row in id_rows]
14751475

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

0 commit comments

Comments
 (0)