Skip to content

Conversation

@Lungsangg
Copy link
Member

No description provided.

@Lungsangg Lungsangg requested a review from lobsam January 2, 2026 05:27
return service.get_thread_by_id(thread_id)


@thread_router.delete("/threads/{thread_id}")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/threads should be at the router level

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to follow the MVC model

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done



@thread_router.delete("/threads/{thread_id}")
def delete_thread(thread_id: UUID, db: Session = Depends(get_db)):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete api should have no response and it should HTTP status 204

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


return messages

def delete_thread_by_id(self, thread_id: UUID) -> dict:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No Response from here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

)

def soft_delete_thread(self, thread_id: UUID) -> bool:
thread = self.db.query(Thread).filter(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we do not have to check if its already deleted for this case.

Just set it to true but take care of thread id not found issue

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NO change here. Still same logic

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NO change here. Still same logic

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Collaborator

@tenzinsamten tenzinsamten left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check thread delete in repository

)

def soft_delete_thread(self, thread_id: UUID) -> bool:
thread = self.db.query(Thread).filter(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NO change here. Still same logic

)

def soft_delete_thread(self, thread_id: UUID) -> bool:
thread = self.db.query(Thread).filter(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NO change here. Still same logic

messages = []
sorted_chats = sorted(chats, key=lambda x: x.created_at)
async def delete_thread_by_id(thread_id: UUID) -> None:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not the optimzation that we talked about because here also you are calling the database 2 times. you just moved the logic from repository to service.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be one Single database operation

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@Lungsangg Lungsangg merged commit 4a94d8b into development Jan 9, 2026
4 checks passed
@Lungsangg Lungsangg deleted the delete_by_thread_id branch January 9, 2026 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants