Skip to content

Conversation

@tishanovartem
Copy link

@tishanovartem tishanovartem commented Nov 12, 2025

Что сделано:

  • В ручке GET /comment/{uuid} теперь возвращаются флаги is_liked и is_disliked, которые показывают поставил ли текущий пользователь лайк/дизлайк на комментарий.
  • Реализован гибридный метод has_reaction() в модели Comment для эффективной проверки реакций пользователь.

Детали реализации

Check-List

  • Вы проверили свой код перед отправкой запроса?
  • Вы написали тесты к реализованным функциям?
  • Вы не забыли применить форматирование black и isort для Back-End или Prettier для Front-End?

@github-actions
Copy link

💩 Code linting failed, use black and isort to fix it.

@github-actions
Copy link

github-actions bot commented Nov 12, 2025

Code Coverage

Coverage Report
FileStmtsMissCoverMissing
rating_api
   __main__.py440%1–7
   exceptions.py43784%35–37, 48–50, 58
rating_api/models
   base.py64494%24–27
   db.py1641889%115, 117, 119, 121, 132, 171, 189, 199, 213, 222–224, 257, 271–279
rating_api/routes
   base.py16194%41
   comment.py1433576%66, 84, 133–134, 155–164, 174, 243–244, 246–247, 260–265, 273, 281–285, 310, 323, 350–361, 392
   exc_handlers.py32391%36, 43, 50
   lecturer.py103991%70–71, 81, 87–88, 207, 215, 233, 239
rating_api/schemas
   models.py165398%230, 232, 242
rating_api/utils
   mark.py880%1–20
TOTAL7889288% 

Summary

Tests Skipped Failures Errors Time
84 0 💤 0 ❌ 0 🔥 30.097s ⏱️

Copy link
Member

@Zimovchik Zimovchik left a comment

Choose a reason for hiding this comment

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

нужно и в ручке get comments тоже это сделать

Comment on lines +268 to +278
@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}
Copy link
Member

Choose a reason for hiding this comment

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

ты можешь сделать это методами алхимии, групнув сджойненые таблички например и посмотрев 1 0 или -1

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.

в get_comment выводить для юзера, лайкнул ли он этот коммент

3 participants