-
Notifications
You must be signed in to change notification settings - Fork 3
Get comment reaction #156
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
base: main
Are you sure you want to change the base?
Get comment reaction #156
Conversation
|
💩 Code linting failed, use |
Coverage Report
Summary
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Zimovchik
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.
нужно и в ручке get comments тоже это сделать
| @classmethod | ||
| def reactions_for_comments(cls, user_id: int, session, comments): | ||
| if not user_id or not comments: | ||
| return {} | ||
| comments_uuid = [c.uuid for c in comments] | ||
| reactions = ( | ||
| session.query(CommentReaction) | ||
| .filter(CommentReaction.user_id == user_id, CommentReaction.comment_uuid.in_(comments_uuid)) | ||
| .all() | ||
| ) | ||
| return {r.comment_uuid: r.reaction for r in reactions} |
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.
ты можешь сделать это методами алхимии, групнув сджойненые таблички например и посмотрев 1 0 или -1
Что сделано:
GET /comment/{uuid}теперь возвращаются флагиis_likedиis_disliked, которые показывают поставил ли текущий пользователь лайк/дизлайк на комментарий.has_reaction()в моделиCommentдля эффективной проверки реакций пользователь.Детали реализации
Check-List
blackиisortдля Back-End илиPrettierдля Front-End?