feat(ui): show total archived chat count in ChatsModal title (#25872)
This commit is contained in:
@@ -831,6 +831,17 @@ class ChatTable:
|
||||
for chat in all_chats
|
||||
]
|
||||
|
||||
async def count_archived_chats_by_user_id(
|
||||
self,
|
||||
user_id: str,
|
||||
db: AsyncSession | None = None,
|
||||
) -> int:
|
||||
async with get_async_db_context(db) as session:
|
||||
result = await session.execute(
|
||||
select(func.count(Chat.id)).filter_by(user_id=user_id, archived=True)
|
||||
)
|
||||
return result.scalar() or 0
|
||||
|
||||
async def get_shared_chat_list_by_user_id(
|
||||
self,
|
||||
user_id: str,
|
||||
|
||||
@@ -819,6 +819,19 @@ async def get_archived_session_user_chat_list(
|
||||
)
|
||||
|
||||
|
||||
############################
|
||||
# GetArchivedChatsCount
|
||||
############################
|
||||
|
||||
|
||||
@router.get('/archived/count', response_model=int)
|
||||
async def get_archived_session_user_chat_count(
|
||||
user=Depends(get_verified_user),
|
||||
db: AsyncSession = Depends(get_async_session),
|
||||
):
|
||||
return await Chats.count_archived_chats_by_user_id(user.id, db=db)
|
||||
|
||||
|
||||
############################
|
||||
# ArchiveAllChats
|
||||
############################
|
||||
|
||||
Reference in New Issue
Block a user