Skip to content

Conversation

@sh1nkey
Copy link
Member

@sh1nkey sh1nkey commented Mar 1, 2024

закончил рефакторинг get запросов в приложении project_rates

return Response(serialized_data, status=status.HTTP_200_OK)
except IndexError:
return Response(
{"error": "Нужный проект или программа не найдены"},
Copy link
Member

Choose a reason for hiding this comment

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

предлагаю завести файлик entities или constants и туда класть строчки с ошибками, в core можно положить какие то общие ошибки. но кажется в дрф и джанге часть ошибок в зависимости от локализации возвращается корректно, тут надо поресерчить и привести все к единому виду. Для начала давай просто вынесем их в файлик.

class Erros(enum.Enum):
    PROJECT_OR_PROGRAM_NOT_FOUND = "..."

Copy link
Member Author

Choose a reason for hiding this comment

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

оговорили это, не актуально

filled_values = sum(
1
for criteria in project_data["criterias"]
if criteria["name"] == "Комментарий" or criteria.get("value")
Copy link
Member

Choose a reason for hiding this comment

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

не понял логику проверки на заполненность
во первых почему мы сравниаем имя критерия с захардкоженным словом "Комментарий" и считаем что если имя комментарий то критерий заполнен?

То есть коммент может быть и пустым, но будет считаться как заполненное поле?

Copy link
Member Author

Choose a reason for hiding this comment

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

комментарий идее опционален

min_value: float | None, max_value: float | None, value: str
):
if min_value is not None and min_value > float(value):
raise ValueError("Оценка этого критерия принизила допустимые значения!")
Copy link
Member

Choose a reason for hiding this comment

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

принизила?) Мб просто Оценка этого критерия меньше допустимого значения

Copy link
Member Author

Choose a reason for hiding this comment

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

исправил

criteria_to_get = [
criterion["criterion_id"] for criterion in data
] # is needed for validation later
for criterion in data:
Copy link
Member

Choose a reason for hiding this comment

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

как переводится criterion? непонятное слово какое то)

Copy link
Member Author

Choose a reason for hiding this comment

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

criterion - критерий (единственное число)
criteria - критерии (множественное число)
criterias - критерии (хуйня которую я по незнанию английского придумал)

Copy link
Member Author

Choose a reason for hiding this comment

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

criterion используется только при получении данных с фронта. мне лень было это везде на бэке исправлять, это ж модели ещё нужно менять...

Copy link
Member

Choose a reason for hiding this comment

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

ааа

@sh1nkey sh1nkey merged commit 71272d3 into dev Mar 12, 2024
@sh1nkey sh1nkey deleted the project_rates_finished_refactoring branch March 18, 2024 06:25
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.

3 participants