From 86e0e6f059345e10850d685155187dfe3888c794 Mon Sep 17 00:00:00 2001 From: Fl1riX Date: Sat, 23 May 2026 15:08:17 +0300 Subject: [PATCH 1/2] fix: Remove the get_db file from infrastructure and remove logging of all SQL queries to reduce the IO load. --- src/infrastructure/db/database.py | 3 +-- src/infrastructure/tasks/get_db.py | 19 ------------------- 2 files changed, 1 insertion(+), 21 deletions(-) delete mode 100644 src/infrastructure/tasks/get_db.py diff --git a/src/infrastructure/db/database.py b/src/infrastructure/db/database.py index 98dd547..e2c7184 100644 --- a/src/infrastructure/db/database.py +++ b/src/infrastructure/db/database.py @@ -6,8 +6,7 @@ DB_URL = f"postgresql+asyncpg://{DATABASE_URL}" engine = create_async_engine( - DB_URL, - echo=True # для отладки + DB_URL ) SessionLocal = async_sessionmaker( diff --git a/src/infrastructure/tasks/get_db.py b/src/infrastructure/tasks/get_db.py deleted file mode 100644 index caadc4e..0000000 --- a/src/infrastructure/tasks/get_db.py +++ /dev/null @@ -1,19 +0,0 @@ -from pathlib import Path -from sqlalchemy.ext.asyncio import create_async_engine, async_sessionmaker, AsyncSession - -BASE_DIR = Path(__file__).resolve().parent.parent.parent.parent - -DB_PATH = BASE_DIR / "Booking-System.db" -DB_URL = f"sqlite+aiosqlite:///{DB_PATH}" - -engine = create_async_engine( - DB_URL, - connect_args={"check_same_thread": False}, - echo=True # для отладки -) - -SessionLocal = async_sessionmaker( - bind=engine, - class_=AsyncSession, - expire_on_commit=False -) \ No newline at end of file From 021fb90777a5876e41e131b19fc5956d5dbcdb40 Mon Sep 17 00:00:00 2001 From: Fl1riX Date: Sat, 23 May 2026 15:14:30 +0300 Subject: [PATCH 2/2] chore(jwt): Remove dprecated definition of the current time --- src/presentation/api/v1/auth/jwt_handler.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/presentation/api/v1/auth/jwt_handler.py b/src/presentation/api/v1/auth/jwt_handler.py index 6ca0050..02a987f 100644 --- a/src/presentation/api/v1/auth/jwt_handler.py +++ b/src/presentation/api/v1/auth/jwt_handler.py @@ -1,4 +1,4 @@ -from datetime import datetime, timedelta +from datetime import datetime, timedelta, timezone from jose import jwt, JWTError from passlib.context import CryptContext from src.logger import logger @@ -19,7 +19,7 @@ def create_access_token(data: dict) -> str: """Создаем JWT токен""" logger.info("Создание JWT токена...") to_encode = data.copy() # копируем данные, чтобы не менять исходный словарь - expire = datetime.utcnow() + timedelta(minutes=ACCESS_TOKEN_EXPIRE_MINUTES) # через сколько токен становится не действительным + expire = datetime.now(timezone.utc) + timedelta(minutes=ACCESS_TOKEN_EXPIRE_MINUTES) # через сколько токен становится не действительным to_encode.update( { "exp": expire,