Pull request for Ilya - #5
Conversation
1 microservice architecture init
| @@ -0,0 +1,3 @@ | |||
| .venv | |||
| __pycache__ | |||
| .idea No newline at end of file | |||
There was a problem hiding this comment.
пустую строчку в конце
|
|
||
| WORKDIR /app/src | ||
|
|
||
| CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8003", "--reload"] No newline at end of file |
There was a problem hiding this comment.
Тут и ниже везде, аналогично
There was a problem hiding this comment.
они тоже имеют шанс на существование
There was a problem hiding this comment.
Вынести бы в тулзы или скрипты сервиса. Не относится к коду самого микросервиса
|
|
||
| async def add_cars(db: AsyncSession, cars: list[CarCreate]) -> list[Car]: | ||
| car_objects = [ | ||
| Car(name=car.name, |
| Car(name=car.name, | ||
| battery_capacity=car.battery_capacity, | ||
| consumpting=car.consumpting, | ||
| type_charger=car.type_charger |
There was a problem hiding this comment.
Запятую после type_charger
| from fastapi import FastAPI, Depends, status | ||
| from sqlalchemy.ext.asyncio import AsyncSession | ||
| from database.database import get_db | ||
| from EV_cars import parse_ev_cars |
| @@ -0,0 +1,10 @@ | |||
| import os | |||
There was a problem hiding this comment.
это просто скопированный код, с моей репы для конфигов, согласен, тут оно не надо.
|
|
||
| @router.post("/register") | ||
| def register(data: RegisterData): | ||
| cursor.execute("SELECT 1 FROM users WHERE email = %s", (data.email,)) |
There was a problem hiding this comment.
Тут уже используется ORM. Когда много разных подходов по коду применяется читать и модифицировать такое сложно
There was a problem hiding this comment.
это старый код, будет переделан.
| return jwt.decode(token, SECRET_KEY, algorithms=[ALGORITHM]) | ||
|
|
||
|
|
||
| # async def authenticate_user(self, db: AsyncSession, login: str, password: str) -> UserInDB | None: |
| hashed_pw = hash_password(data.password) | ||
|
|
||
| cursor.execute( | ||
| "INSERT INTO users (email, password_hash, role) VALUES (%s, %s, %s)", |
There was a problem hiding this comment.
Вообще не понял, чем у тебя прокся занимается: проксированием, или всем?
|
Чем тебе пустые строчки не угодили? |
ZhuchkaTriplesix
left a comment
There was a problem hiding this comment.
make пустые строчки great again
|
|
||
| WORKDIR /app/src | ||
|
|
||
| CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8003", "--reload"] No newline at end of file |
There was a problem hiding this comment.
они тоже имеют шанс на существование
There was a problem hiding this comment.
справедливо, если будет время, то вынесу
There was a problem hiding this comment.
добавить редис(вроде как было указано в дипломе)
| @@ -0,0 +1,10 @@ | |||
| import os | |||
There was a problem hiding this comment.
это просто скопированный код, с моей репы для конфигов, согласен, тут оно не надо.
There was a problem hiding this comment.
вынести миддлварю и регистрацию роутеров в конфигурацию.
|
|
||
| @router.post("/register") | ||
| def register(data: RegisterData): | ||
| cursor.execute("SELECT 1 FROM users WHERE email = %s", (data.email,)) |
There was a problem hiding this comment.
это старый код, будет переделан.
| hashed_pw = hash_password(data.password) | ||
|
|
||
| cursor.execute( | ||
| "INSERT INTO users (email, password_hash, role) VALUES (%s, %s, %s)", |
| login=new_user.login, | ||
| car_id=new_user.car_id) | ||
| except IntegrityError as ie: | ||
| await db.rollback() |
There was a problem hiding this comment.
роллбек у тебя в генераторе сессии уже есть.
No description provided.