"...resnet50_tensorflow.git" did not exist on "66404fbbecba33a8b98db07a696d60332b600768"
Commit 1d937ec2 authored by Timothy J. Baek's avatar Timothy J. Baek
Browse files

fix: cleanup unused tags

parent 7c1b8e39
...@@ -9,11 +9,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ...@@ -9,11 +9,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added ### Added
- **🔄 Check for Updates**: Now conveniently available in Settings > About. - **🔄 Check for Updates**: Keep your system current by checking for updates conveniently located in Settings > About.
- **🗑️ Automatic Tag Deletion**: Unused tags on the sidebar will now be deleted automatically with just a click.
### Changed ### Changed
- **🎨 Modernized Styling**: Updated for a more contemporary appearance. - **🎨 Modernized Styling**: Enjoy a refreshed look with updated styling for a more contemporary experience.
## [0.1.103] - 2024-02-25 ## [0.1.103] - 2024-02-25
......
...@@ -167,6 +167,27 @@ class TagTable: ...@@ -167,6 +167,27 @@ class TagTable:
.count() .count()
) )
def delete_tag_by_tag_name_and_user_id(self, tag_name: str, user_id: str) -> bool:
try:
query = ChatIdTag.delete().where(
(ChatIdTag.tag_name == tag_name) & (ChatIdTag.user_id == user_id)
)
res = query.execute() # Remove the rows, return number of rows removed.
print(res)
tag_count = self.count_chat_ids_by_tag_name_and_user_id(tag_name, user_id)
if tag_count == 0:
# Remove tag item from Tag col as well
query = Tag.delete().where(
(Tag.name == tag_name) & (Tag.user_id == user_id)
)
query.execute() # Remove the rows, return number of rows removed.
return True
except Exception as e:
print("delete_tag", e)
return False
def delete_tag_by_tag_name_and_chat_id_and_user_id( def delete_tag_by_tag_name_and_chat_id_and_user_id(
self, tag_name: str, chat_id: str, user_id: str self, tag_name: str, chat_id: str, user_id: str
) -> bool: ) -> bool:
......
...@@ -115,9 +115,12 @@ async def get_user_chats_by_tag_name( ...@@ -115,9 +115,12 @@ async def get_user_chats_by_tag_name(
for chat_id_tag in Tags.get_chat_ids_by_tag_name_and_user_id(tag_name, user.id) for chat_id_tag in Tags.get_chat_ids_by_tag_name_and_user_id(tag_name, user.id)
] ]
print(chat_ids) chats = Chats.get_chat_lists_by_chat_ids(chat_ids, skip, limit)
return Chats.get_chat_lists_by_chat_ids(chat_ids, skip, limit) if len(chats) == 0:
Tags.delete_tag_by_tag_name_and_user_id(tag_name, user.id)
return chats
############################ ############################
......
...@@ -13,7 +13,8 @@ ...@@ -13,7 +13,8 @@
getChatList, getChatList,
getChatById, getChatById,
getChatListByTagName, getChatListByTagName,
updateChatById updateChatById,
getAllChatTags
} from '$lib/apis/chats'; } from '$lib/apis/chats';
import toast from 'svelte-french-toast'; import toast from 'svelte-french-toast';
import { slide } from 'svelte/transition'; import { slide } from 'svelte/transition';
...@@ -330,7 +331,12 @@ ...@@ -330,7 +331,12 @@
<button <button
class="px-2.5 text-xs font-medium bg-gray-900 hover:bg-gray-800 transition rounded-full" class="px-2.5 text-xs font-medium bg-gray-900 hover:bg-gray-800 transition rounded-full"
on:click={async () => { on:click={async () => {
await chats.set(await getChatListByTagName(localStorage.token, tag.name)); let chatIds = await getChatListByTagName(localStorage.token, tag.name);
if (chatIds.length === 0) {
await tags.set(await getAllChatTags(localStorage.token));
chatIds = await getChatList(localStorage.token);
}
await chats.set(chatIds);
}} }}
> >
{tag.name} {tag.name}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment