Skip to content
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

this comment time and create minutes #65

Closed
wants to merge 6 commits into from
Closed

Conversation

ValeryEstal
Copy link

Изменения

Внесены изменения в классы:
Заменены минуты на месяцы
Изменено отображение даты

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

Check-List

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

@ValeryEstal ValeryEstal requested a review from DaymasS December 4, 2024 14:28
Copy link

github-actions bot commented Dec 4, 2024

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

Copy link

github-actions bot commented Dec 4, 2024

Code Coverage

Coverage Report
FileStmtsMissCoverMissing
rating_api
   __main__.py440%1–7
   exceptions.py26292%35–36
rating_api/models
   base.py55198%76
   db.py73297%61, 74
rating_api/routes
   comment.py872967%32–34, 38, 50–100, 143, 153–158, 165, 188, 204
   exc_handlers.py20195%26
   lecturer.py841483%132–153, 169, 177, 195, 201
TOTAL4685389% 

Summary

Tests Skipped Failures Errors Time
44 0 💤 8 ❌ 0 🔥 5.902s ⏱️

+ datetime.timedelta(year=settings.COMMENT_CREATE_FREQUENCY_IN_YEAR)
- datetime.datetime.now().month
- datetime.datetime.now().year
)
# Сначала добавляем с user_id, который мы получили при авторизации,
# в LecturerUserComment, чтобы нельзя было слишком быстро добавлять комментарии
LecturerUserComment.create(session=db.session, lecturer_id=lecturer_id, user_id=user.get('id'))
Copy link
Contributor

Choose a reason for hiding this comment

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

Создавать запись о комментарии юзера нужно с точностью до месяца

if datetime.datetime.now().month - user_comment.update_ts < datetime.timedelta(
month=settings.COMMENT_CREATE_FREQUENCY_IN_MONTH
) and datetime.datetime.now().year != datetime.timedelta(
year=settings.COMMENT_CREATE_FREQUENCY_IN_YEAR
Copy link
Contributor

Choose a reason for hiding this comment

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

Частота в годах не нужна

Comment on lines 33 to 50
has_create_scope = "rating.comment.import" in [scope['name'] for scope in user.get('session_scopes')]
if (comment_info.create_ts or comment_info.update_ts) and not has_create_scope:
raise ForbiddenAction(Comment)

if not has_create_scope:
user_comments: list[LecturerUserComment] = (
LecturerUserComment.query(session=db.session).filter(LecturerUserComment.user_id == user.get("id")).all()
)
for user_comment in user_comments:
if datetime.datetime.utcnow() - user_comment.update_ts < datetime.timedelta(
minutes=settings.COMMENT_CREATE_FREQUENCY_IN_MINUTES
):
raise TooManyCommentRequests(
dtime=user_comment.update_ts
+ datetime.timedelta(minutes=settings.COMMENT_CREATE_FREQUENCY_IN_MINUTES)
- datetime.datetime.utcnow()
)

Copy link
Contributor

Choose a reason for hiding this comment

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

Не корректное разрешение коллизии. Необходимо сохранить проверку скоупов на задание ts

Copy link

github-actions bot commented Dec 6, 2024

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

Copy link

github-actions bot commented Dec 6, 2024

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

Copy link

github-actions bot commented Dec 6, 2024

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

Copy link

github-actions bot commented Dec 6, 2024

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

@ValeryEstal ValeryEstal requested a review from DaymasS December 6, 2024 06:11
Copy link

github-actions bot commented Dec 6, 2024

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

@DaymasS DaymasS closed this Dec 6, 2024
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.

2 participants