Skip to content

Conversation

Temmmmmo
Copy link
Member

Изменения

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

Check-List

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

Copy link

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

Copy link

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

Copy link

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

Copy link

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

@@ -13,11 +13,7 @@ def __init__(self, eng: str, ru: str) -> None:

class ObjectNotFound(RatingAPIError):

Choose a reason for hiding this comment

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

[КРИТИЧНО] Конструктор класса не инициализирует базовый класс

@@ -72,6 +70,5 @@ def delete(cls, id: int | str, *, session: Session) -> None:
obj = cls.get(id, session=session)

Choose a reason for hiding this comment

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

[КРИТИЧНО] Логическая ошибка в обновлении атрибутов объекта**

@@ -55,14 +55,12 @@ def get(cls, id: int | str, *, with_deleted=False, session: Session) -> BaseDbMo
if hasattr(cls, "uuid"):

Choose a reason for hiding this comment

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

[КРИТИЧНО] Логическая ошибка в методе удаления объекта**

@@ -55,14 +55,12 @@ def get(cls, id: int | str, *, with_deleted=False, session: Session) -> BaseDbMo
if hasattr(cls, "uuid"):

Choose a reason for hiding this comment

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

[СТИЛЬ] Избыточный вывод информации**

raise ForbiddenSymbol()
# if re.search(r"^[a-zA-Zа-яА-Я\d!?,_\-.\"\'\[\]{}`~<>^@#№$%;:&*()+=\\\/ \n]*$", comment_info.text) is None:
# raise ForbiddenSymbol()

# Сначала добавляем с user_id, который мы получили при авторизации,
# в LecturerUserComment, чтобы нельзя было слишком быстро добавлять комментарии

Choose a reason for hiding this comment

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

[КРИТИЧНО] Закомментированный код проверки на запрещенные символы

@@ -102,7 +102,6 @@ async def create_comment(lecturer_id: int, comment_info: CommentPost, user=Depen
user_id = None if comment_info.is_anonymous else user.get('id')

new_comment = Comment.create(

Choose a reason for hiding this comment

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

[УЛУЧШЕНИЕ] Удаление параметра session из вызова метода create

@@ -116,7 +115,7 @@ async def create_comment(lecturer_id: int, comment_info: CommentPost, user=Depen
settings.API_URL + f"achievement/user/{user.get('id'):}",
headers={"Accept": "application/json"},
) as response:
if response.status == 200:
if response.status == 300:
user_achievements = await response.json()
for achievement in user_achievements.get("achievement", []):
if achievement.get("id") == settings.FIRST_COMMENT_ACHIEVEMENT_ID:

Choose a reason for hiding this comment

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

[КРИТИЧНО] Изменение статуса ответа с 200 на 300

@@ -17,7 +17,7 @@
from .base import app


@app.exception_handler(ObjectNotFound)
@app.exception_handler(AlreadyExists)
async def not_found_handler(req: starlette.requests.Request, exc: ObjectNotFound):

Choose a reason for hiding this comment

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

[КРИТИЧНО] Несоответствие типа исключения и обработчика

@@ -17,7 +17,7 @@
from .base import app


@app.exception_handler(ObjectNotFound)
@app.exception_handler(AlreadyExists)
async def not_found_handler(req: starlette.requests.Request, exc: ObjectNotFound):

Choose a reason for hiding this comment

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

[УЛУЧШЕНИЕ] Использование неправильного статуса ответа

@@ -18,8 +18,6 @@ class CommentGet(Base):
mark_kindness: int
mark_freebie: int
mark_clarity: int

Choose a reason for hiding this comment

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

[СТИЛЬ] Отсутствует документация класса

@@ -13,11 +13,7 @@ def __init__(self, eng: str, ru: str) -> None:

class ObjectNotFound(RatingAPIError):

Choose a reason for hiding this comment

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

[КРИТИЧНО] Удалено сообщение об ошибке

@@ -72,6 +70,5 @@ def delete(cls, id: int | str, *, session: Session) -> None:
obj = cls.get(id, session=session)
if hasattr(obj, "is_deleted"):
obj.is_deleted = True
else:
session.delete(obj)
print(cls.id, cls.session, session)
session.flush()

Choose a reason for hiding this comment

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

[КРИТИЧНО] Неправильное использование метода setattr

@@ -55,14 +55,12 @@ def get(cls, id: int | str, *, with_deleted=False, session: Session) -> BaseDbMo
if hasattr(cls, "uuid"):

Choose a reason for hiding this comment

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

[КРИТИЧНО] Удаление объекта из сессии не выполняется

@@ -55,14 +55,12 @@ def get(cls, id: int | str, *, with_deleted=False, session: Session) -> BaseDbMo
if hasattr(cls, "uuid"):

Choose a reason for hiding this comment

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

[СТИЛЬ] Лишний вывод в консоль

@@ -84,9 +84,9 @@ async def create_comment(lecturer_id: int, comment_info: CommentPost, user=Depen

if len(comment_info.text) > settings.MAX_COMMENT_LENGTH:

Choose a reason for hiding this comment

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

[КРИТИЧНО] Проверка на запрещенные символы закомментирована

@@ -84,9 +84,9 @@ async def create_comment(lecturer_id: int, comment_info: CommentPost, user=Depen

if len(comment_info.text) > settings.MAX_COMMENT_LENGTH:

Choose a reason for hiding this comment

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

[ВАЖНО] Удаление параметра session при создании комментария

@@ -116,7 +115,7 @@ async def create_comment(lecturer_id: int, comment_info: CommentPost, user=Depen
settings.API_URL + f"achievement/user/{user.get('id'):}",
headers={"Accept": "application/json"},
) as response:

Choose a reason for hiding this comment

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

[КРИТИЧНО] Неправильная проверка статуса ответа

@@ -17,7 +17,7 @@
from .base import app


@app.exception_handler(ObjectNotFound)
@app.exception_handler(AlreadyExists)

Choose a reason for hiding this comment

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

[КРИТИЧНО] Несоответствие типа исключения

@@ -17,7 +17,7 @@
from .base import app


@app.exception_handler(ObjectNotFound)
@app.exception_handler(AlreadyExists)
async def not_found_handler(req: starlette.requests.Request, exc: ObjectNotFound):

Choose a reason for hiding this comment

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

[СТИЛЬ] Неправильный статус кода

@@ -18,8 +18,6 @@ class CommentGet(Base):
mark_kindness: int

Choose a reason for hiding this comment

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

[УЛУЧШЕНИЕ] Удаление полей без комментария

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.

1 participant