-
Notifications
You must be signed in to change notification settings - Fork 0
Delete by thread #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
chat_api/threads/thread_views.py
Outdated
| return service.get_thread_by_id(thread_id) | ||
|
|
||
|
|
||
| @thread_router.delete("/threads/{thread_id}") |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
chat_api/threads/thread_views.py
Outdated
|
|
||
|
|
||
| @thread_router.delete("/threads/{thread_id}") | ||
| def delete_thread(thread_id: UUID, db: Session = Depends(get_db)): |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
chat_api/threads/thread_service.py
Outdated
|
|
||
| return messages | ||
|
|
||
| def delete_thread_by_id(self, thread_id: UUID) -> dict: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No Response from here
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
tenzinsamten
left a comment
There was a problem hiding this 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( |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
No description provided.