This commit is contained in:
Timothy Jaeryang Baek
2026-07-26 23:54:16 -04:00
parent ba7c95f7ef
commit e5a08d5220
6 changed files with 106 additions and 1 deletions
+15
View File
@@ -694,6 +694,21 @@ class ChatTable:
await session.commit()
return result.rowcount or 0
async def mark_root_chats_read_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(
update(Chat)
.where(
Chat.user_id == user_id,
Chat.folder_id.is_(None),
Chat.archived == False,
Chat.meta['internal'].as_boolean().is_not(True),
)
.values(last_read_at=Chat.updated_at)
)
await session.commit()
return result.rowcount or 0
async def update_chat_title_by_id(self, id: str, title: str) -> ChatModel | None:
try:
async with get_async_db_context() as session:
+8
View File
@@ -255,6 +255,14 @@ async def get_session_user_chat_list(
raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail=ERROR_MESSAGES.DEFAULT())
@router.post('/read')
async def mark_root_chats_read_by_user_id(
user=Depends(get_verified_user),
db: AsyncSession = Depends(get_async_session),
):
return {'updated_count': await Chats.mark_root_chats_read_by_user_id(user.id, db=db)}
############################
# GetChatUsageStats
# EXPERIMENTAL: may be removed in future releases