átlagos kiegészítséek jó sok
This commit is contained in:
@@ -6,30 +6,30 @@ from app.models.address import Address, GeoPostalCode, GeoStreet, GeoStreetType,
|
||||
|
||||
from app.models.identity import Person, User, Wallet, VerificationToken, SocialAccount # noqa
|
||||
|
||||
from app.models.organization import Organization, OrganizationMember, OrganizationFinancials, OrganizationSalesAssignment # noqa
|
||||
from app.models.marketplace.organization import Organization, OrganizationMember, OrganizationFinancials, OrganizationSalesAssignment # noqa
|
||||
|
||||
from app.models.service import ServiceProfile, ExpertiseTag, ServiceExpertise, ServiceStaging, DiscoveryParameter # noqa
|
||||
from app.models.marketplace.service import ServiceProfile, ExpertiseTag, ServiceExpertise, ServiceStaging, DiscoveryParameter # noqa
|
||||
|
||||
from app.models.vehicle_definitions import VehicleType, VehicleModelDefinition, FeatureDefinition # noqa
|
||||
from app.models import VehicleType, VehicleModelDefinition, FeatureDefinition # noqa
|
||||
|
||||
from app.models.audit import SecurityAuditLog, OperationalLog, FinancialLedger # noqa <--- KRITIKUS!
|
||||
from app.models import SecurityAuditLog, OperationalLog, FinancialLedger # noqa <--- KRITIKUS!
|
||||
|
||||
from app.models.asset import ( # noqa
|
||||
from app.models import ( # noqa
|
||||
Asset, AssetCatalog, AssetCost, AssetEvent,
|
||||
AssetFinancials, AssetTelemetry, AssetReview, ExchangeRate
|
||||
)
|
||||
|
||||
from app.models.gamification import PointRule, LevelConfig, UserStats, Badge, UserBadge, PointsLedger # noqa
|
||||
from app.models import PointRule, LevelConfig, UserStats, Badge, UserBadge, PointsLedger # noqa
|
||||
|
||||
from app.models.system import SystemParameter # noqa (system.py használata)
|
||||
|
||||
from app.models.history import AuditLog, VehicleOwnership # noqa
|
||||
from app.models import AuditLog, VehicleOwnership # noqa
|
||||
|
||||
from app.models.document import Document # noqa
|
||||
from app.models import Document # noqa
|
||||
|
||||
from app.models.translation import Translation # noqa
|
||||
from app.models import Translation # noqa
|
||||
|
||||
from app.models.core_logic import ( # noqa
|
||||
SubscriptionTier, OrganizationSubscription, CreditTransaction, ServiceSpecialty
|
||||
)
|
||||
from app.models.security import PendingAction # noqa
|
||||
from app.models import PendingAction # noqa
|
||||
@@ -1,7 +1,7 @@
|
||||
# /opt/docker/dev/service_finder/backend/app/db/middleware.py
|
||||
from fastapi import Request
|
||||
from app.db.session import AsyncSessionLocal
|
||||
from app.models.audit import OperationalLog # JAVÍTVA: Az új modell
|
||||
from app.models import OperationalLog # JAVÍTVA: Az új modell
|
||||
from sqlalchemy import text
|
||||
|
||||
async def audit_log_middleware(request: Request, call_next):
|
||||
|
||||
@@ -9,7 +9,8 @@ engine = create_async_engine(
|
||||
future=True,
|
||||
pool_size=30, # A robotok száma miatt
|
||||
max_overflow=20,
|
||||
pool_pre_ping=True
|
||||
pool_pre_ping=True,
|
||||
pool_reset_on_return='rollback'
|
||||
)
|
||||
|
||||
AsyncSessionLocal = async_sessionmaker(
|
||||
@@ -21,8 +22,20 @@ AsyncSessionLocal = async_sessionmaker(
|
||||
|
||||
async def get_db() -> AsyncGenerator[AsyncSession, None]:
|
||||
async with AsyncSessionLocal() as session:
|
||||
# Start with a clean transaction state by rolling back any failed transaction
|
||||
try:
|
||||
await session.rollback()
|
||||
except Exception:
|
||||
# If rollback fails, it's probably because there's no transaction
|
||||
# This is fine, just continue
|
||||
pass
|
||||
|
||||
try:
|
||||
yield session
|
||||
# JAVÍTVA: Nincs automatikus commit! Az endpoint felelőssége.
|
||||
except Exception:
|
||||
# If any exception occurs, rollback the transaction
|
||||
await session.rollback()
|
||||
raise
|
||||
finally:
|
||||
# Ensure session is closed
|
||||
await session.close()
|
||||
Reference in New Issue
Block a user