add logs
This commit is contained in:
parent
8e79c4731b
commit
aaa02622e7
|
|
@ -21,9 +21,19 @@ async def lifespan(app: FastAPI):
|
||||||
# TEMPORARY: Clean up old deleted assets (remove this after first run)
|
# TEMPORARY: Clean up old deleted assets (remove this after first run)
|
||||||
from app.infra.database import AsyncSessionLocal
|
from app.infra.database import AsyncSessionLocal
|
||||||
from sqlalchemy import text
|
from sqlalchemy import text
|
||||||
|
import logging
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
async with AsyncSessionLocal() as session:
|
async with AsyncSessionLocal() as session:
|
||||||
await session.execute(text("DELETE FROM assets WHERE status = 'deleted'"))
|
# Check how many deleted assets exist
|
||||||
|
result = await session.execute(text("SELECT COUNT(*) FROM assets WHERE status = 'deleted'"))
|
||||||
|
count_before = result.scalar()
|
||||||
|
logger.info(f"Found {count_before} assets with status='deleted'")
|
||||||
|
|
||||||
|
# Delete them
|
||||||
|
result = await session.execute(text("DELETE FROM assets WHERE status = 'deleted'"))
|
||||||
await session.commit()
|
await session.commit()
|
||||||
|
logger.info(f"Deleted {result.rowcount} assets with status='deleted'")
|
||||||
# END TEMPORARY
|
# END TEMPORARY
|
||||||
|
|
||||||
yield
|
yield
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue