-
Notifications
You must be signed in to change notification settings - Fork 1
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
Conversation
💩 Code linting failed, use |
Coverage Report
Summary
|
rating_api/routes/comment.py
Outdated
+ 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')) |
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.
Создавать запись о комментарии юзера нужно с точностью до месяца
rating_api/routes/comment.py
Outdated
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 |
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.
Частота в годах не нужна
rating_api/routes/comment.py
Outdated
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() | ||
) | ||
|
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.
Не корректное разрешение коллизии. Необходимо сохранить проверку скоупов на задание ts
💩 Code linting failed, use |
💩 Code linting failed, use |
💩 Code linting failed, use |
💩 Code linting failed, use |
💩 Code linting failed, use |
Изменения
Внесены изменения в классы:
Заменены минуты на месяцы
Изменено отображение даты
Детали реализации
Check-List
black
иisort
для Back-End илиPrettier
для Front-End?