-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/user skills #499
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
base: dev
Are you sure you want to change the base?
Feature/user skills #499
Conversation
| filterset_class = UserFilter | ||
|
|
||
| def list(self, request, *args, **kwargs): | ||
| max_skills = request.query_params.get("max_skills", None) |
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.
это нужно прокинуть в контекст сериалайзера, чтобы мы из БД тянули скиллы с лимитом, а не вытаскивали ВСЕ и потом обрезали вывод
|
|
||
| def list(self, request, *args, **kwargs): | ||
| max_skills = request.query_params.get("max_skills", None) | ||
| if max_skills is not None: |
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.
валидацию квери параметров может сделать через сериалайзер? то, что вьюшка занимается валидацией квери параметров мне кажется не ок
| for user_data in response.data.get("results", []): | ||
| if "skills" in user_data: | ||
| user_data["skills"] = user_data["skills"][:max_skills] | ||
|
|
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.
это должно быть учтено при походе в БД, точно не стоит обрезать кусок ответа во вьюшке)
| max_skills = request.query_params.get("max_skills", None) | ||
| if max_skills is not None: | ||
| try: | ||
| max_skills = int(max_skills) | ||
| if max_skills < 0: | ||
| return Response( | ||
| {"error": "max_skills must be a positive integer"}, | ||
| status=status.HTTP_400_BAD_REQUEST, | ||
| ) | ||
| except ValueError: | ||
| return Response( | ||
| {"error": "max_skills must be an integer"}, | ||
| status=status.HTTP_400_BAD_REQUEST, | ||
| ) | ||
|
|
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.
лютая копипаста, точно нужно убрать это отсюда
| max_skills = int(max_skills) | ||
| if max_skills < 0: | ||
| return Response( | ||
| {"error": "max_skills must be a positive integer"}, |
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.
да зачем тут ошибку отдавать, давай просто считать что max_skills = 0 и не будем вообще эти скиллы получать из бд
| filterset_class = UserFilter | ||
|
|
||
| def list(self, request, *args, **kwargs): | ||
| max_skills = request.query_params.get("max_skills", None) |
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.
давай тут вместо None какой-нибудь разумный дефолт бахнем? сейчас фронт все равно не передает этот квери параметр и после мержа этого ПРа он продолжит забирать кучу лишних данных, а с дефолтом мы этот размер ограничим
Краткое название
Добавлен query arg для выставления максимального количества skills в ручке users
Описание изменений
Опишите изменения, которые вы внесли в код. Не забывайте указывать номер задачи или ссылку на тикет.
Тестирование
Опишите, как тестировали свои изменения. Например, какие тесты проходят, а какие нет.
Проверка кода
Опишите, как проверить ваш код.
Дополнительная информация
Здесь вы можете добавить какую-либо дополнительную информацию о своих изменениях.