fix/various fixes

This commit is contained in:
Kevin
2026-03-20 15:15:35 +08:00
parent 7f57f96c25
commit 7317bf10cd
112 changed files with 3790 additions and 2242 deletions

View File

@@ -15,7 +15,10 @@ async def get_conversation(
async def get_user_conversations(user_id: str, db: AsyncSession) -> list[Conversation]:
stmt = (
select(Conversation)
.where(Conversation.user_id == user_id)
.where(
Conversation.user_id == user_id,
Conversation.deleted_at.is_(None),
)
.order_by(
func.coalesce(Conversation.last_message_at, Conversation.started_at).desc()
)
@@ -64,7 +67,10 @@ async def count_segments_for_user(user_id: str, db: AsyncSession) -> int:
select(func.count(Segment.id))
.select_from(Segment)
.join(Conversation, Segment.conversation_id == Conversation.id)
.where(Conversation.user_id == user_id)
.where(
Conversation.user_id == user_id,
Conversation.deleted_at.is_(None),
)
)
result = await db.execute(stmt)
return result.scalar() or 0