Skip to content

Pull request for Ilya - #5

Open
RoKivals wants to merge 16 commits into
old_versionfrom
Ilya_pr
Open

Pull request for Ilya#5
RoKivals wants to merge 16 commits into
old_versionfrom
Ilya_pr

Conversation

@RoKivals

Copy link
Copy Markdown
Owner

No description provided.

@Relloading Relloading assigned Relloading and unassigned Relloading May 26, 2025
@@ -0,0 +1,3 @@
.venv
__pycache__
.idea No newline at end of file

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

пустую строчку в конце


WORKDIR /app/src

CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8003", "--reload"] No newline at end of file

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Тут и ниже везде, аналогично

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

они тоже имеют шанс на существование

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Вынести бы в тулзы или скрипты сервиса. Не относится к коду самого микросервиса


async def add_cars(db: AsyncSession, cars: list[CarCreate]) -> list[Car]:
car_objects = [
Car(name=car.name,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Перенос строки

Car(name=car.name,
battery_capacity=car.battery_capacity,
consumpting=car.consumpting,
type_charger=car.type_charger

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Запятую после 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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Лишнее?

@@ -0,0 +1,10 @@
import os

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

А гейтвею зачем база?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

это просто скопированный код, с моей репы для конфигов, согласен, тут оно не надо.


@router.post("/register")
def register(data: RegisterData):
cursor.execute("SELECT 1 FROM users WHERE email = %s", (data.email,))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Тут уже используется ORM. Когда много разных подходов по коду применяется читать и модифицировать такое сложно

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

это старый код, будет переделан.

return jwt.decode(token, SECRET_KEY, algorithms=[ALGORITHM])


# async def authenticate_user(self, db: AsyncSession, login: str, password: str) -> UserInDB | None:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Лишнее?

hashed_pw = hash_password(data.password)

cursor.execute(
"INSERT INTO users (email, password_hash, role) VALUES (%s, %s, %s)",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Вообще не понял, чем у тебя прокся занимается: проксированием, или всем?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

кайфует

@ZhuchkaTriplesix

Copy link
Copy Markdown
Collaborator

Чем тебе пустые строчки не угодили?

@ZhuchkaTriplesix ZhuchkaTriplesix left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

make пустые строчки great again


WORKDIR /app/src

CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8003", "--reload"] No newline at end of file

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

они тоже имеют шанс на существование

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

справедливо, если будет время, то вынесу

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

добавить редис(вроде как было указано в дипломе)

@@ -0,0 +1,10 @@
import os

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

это просто скопированный код, с моей репы для конфигов, согласен, тут оно не надо.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

вынести миддлварю и регистрацию роутеров в конфигурацию.


@router.post("/register")
def register(data: RegisterData):
cursor.execute("SELECT 1 FROM users WHERE email = %s", (data.email,))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

это старый код, будет переделан.

hashed_pw = hash_password(data.password)

cursor.execute(
"INSERT INTO users (email, password_hash, role) VALUES (%s, %s, %s)",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

кайфует

login=new_user.login,
car_id=new_user.car_id)
except IntegrityError as ie:
await db.rollback()

Copy link
Copy Markdown
Collaborator

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.

3 participants