fix: duplicate tags

This commit is contained in:
Timothy J. Baek 2024-10-14 23:04:10 -07:00
parent 9d2d53bfb5
commit cf24a65caa
2 changed files with 3 additions and 3 deletions

View File

@ -561,7 +561,7 @@ class ChatTable:
if tag_id not in chat.meta.get("tags", []):
chat.meta = {
**chat.meta,
"tags": chat.meta.get("tags", []) + [tag_id],
"tags": list(set(chat.meta.get("tags", []) + [tag_id])),
}
db.commit()
@ -618,7 +618,7 @@ class ChatTable:
tags = [tag for tag in tags if tag != tag_id]
chat.meta = {
**chat.meta,
"tags": tags,
"tags": list(set(tags)),
}
db.commit()
return True

View File

@ -135,7 +135,7 @@ def upgrade():
tags = chat_updates[chat_id]["meta"].get("tags", [])
tags.append(tag_name)
chat_updates[chat_id]["meta"]["tags"] = tags
chat_updates[chat_id]["meta"]["tags"] = list(set(tags))
# Update chats based on accumulated changes
for chat_id, updates in chat_updates.items():