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,7 @@
# app/tasks/background_tasks.py
import logging
from datetime import datetime
from app.core.database import SessionLocal
from models.database_models import MarketplaceImportJob
from utils.csv_processor import CSVProcessor
@@ -9,11 +10,7 @@ logger = logging.getLogger(__name__)
async def process_marketplace_import(
job_id: int,
url: str,
marketplace: str,
shop_name: str,
batch_size: int = 1000
job_id: int, url: str, marketplace: str, shop_name: str, batch_size: int = 1000
):
"""Background task to process marketplace CSV import"""
db = SessionLocal()
@@ -22,7 +19,11 @@ async def process_marketplace_import(
try:
# Update job status
job = db.query(MarketplaceImportJob).filter(MarketplaceImportJob.id == job_id).first()
job = (
db.query(MarketplaceImportJob)
.filter(MarketplaceImportJob.id == job_id)
.first()
)
if not job:
logger.error(f"Import job {job_id} not found")
return
@@ -70,7 +71,7 @@ async def process_marketplace_import(
finally:
# Close the database session only if it's not a mock
# In tests, we use the same session so we shouldn't close it
if hasattr(db, 'close') and callable(getattr(db, 'close')):
if hasattr(db, "close") and callable(getattr(db, "close")):
try:
db.close()
except Exception as close_error: