code quality run

This commit is contained in:
2025-09-13 21:58:54 +02:00
parent 0dfd885847
commit 3eb18ef91e
63 changed files with 1802 additions and 1289 deletions

View File

@@ -1,6 +1,8 @@
# app/core/config.py
from pydantic_settings import BaseSettings # This is the correct import for Pydantic v2
from typing import Optional, List
from typing import List, Optional
from pydantic_settings import \
BaseSettings # This is the correct import for Pydantic v2
class Settings(BaseSettings):

View File

@@ -1,6 +1,6 @@
from sqlalchemy import create_engine
from sqlalchemy.orm import declarative_base
from sqlalchemy.orm import sessionmaker
from sqlalchemy.orm import declarative_base, sessionmaker
from .config import settings
engine = create_engine(settings.database_url)

View File

@@ -1,11 +1,14 @@
import logging
from contextlib import asynccontextmanager
from fastapi import FastAPI
from sqlalchemy import text
from .logging import setup_logging
from .database import engine, SessionLocal
from models.database_models import Base
import logging
from middleware.auth import AuthManager
from models.database_models import Base
from .database import SessionLocal, engine
from .logging import setup_logging
logger = logging.getLogger(__name__)
auth_manager = AuthManager()
@@ -44,15 +47,29 @@ def create_indexes():
with engine.connect() as conn:
try:
# User indexes
conn.execute(text("CREATE INDEX IF NOT EXISTS idx_user_email ON users(email)"))
conn.execute(text("CREATE INDEX IF NOT EXISTS idx_user_username ON users(username)"))
conn.execute(
text("CREATE INDEX IF NOT EXISTS idx_user_email ON users(email)")
)
conn.execute(
text("CREATE INDEX IF NOT EXISTS idx_user_username ON users(username)")
)
# Product indexes
conn.execute(text("CREATE INDEX IF NOT EXISTS idx_product_gtin ON products(gtin)"))
conn.execute(text("CREATE INDEX IF NOT EXISTS idx_product_marketplace ON products(marketplace)"))
conn.execute(
text("CREATE INDEX IF NOT EXISTS idx_product_gtin ON products(gtin)")
)
conn.execute(
text(
"CREATE INDEX IF NOT EXISTS idx_product_marketplace ON products(marketplace)"
)
)
# Stock indexes
conn.execute(text("CREATE INDEX IF NOT EXISTS idx_stock_gtin_location ON stock(gtin, location)"))
conn.execute(
text(
"CREATE INDEX IF NOT EXISTS idx_stock_gtin_location ON stock(gtin, location)"
)
)
conn.commit()
logger.info("Database indexes created successfully")

View File

@@ -2,6 +2,7 @@
import logging
import sys
from pathlib import Path
from app.core.config import settings
@@ -22,7 +23,7 @@ def setup_logging():
# Create formatters
formatter = logging.Formatter(
'%(asctime)s - %(name)s - %(levelname)s - %(message)s'
"%(asctime)s - %(name)s - %(levelname)s - %(message)s"
)
# Console handler