fix/various fixes
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user