átlagos kiegészítséek jó sok
This commit is contained in:
@@ -21,9 +21,9 @@ from apscheduler.jobstores.memory import MemoryJobStore
|
||||
|
||||
from app.database import AsyncSessionLocal
|
||||
from app.services.billing_engine import SmartDeduction
|
||||
from app.models.payment import WithdrawalRequest, WithdrawalRequestStatus
|
||||
from app.models.marketplace.payment import WithdrawalRequest, WithdrawalRequestStatus
|
||||
from app.models.identity import User
|
||||
from app.models.audit import ProcessLog, WalletType, FinancialLedger
|
||||
from app.models import ProcessLog, WalletType, FinancialLedger
|
||||
from sqlalchemy import select, update, and_
|
||||
from sqlalchemy.orm import selectinload
|
||||
|
||||
@@ -152,12 +152,16 @@ async def daily_financial_maintenance() -> None:
|
||||
stats["errors"].append(f"Soft downgrade error: {str(e)}")
|
||||
logger.error(f"Soft downgrade error: {e}", exc_info=True)
|
||||
|
||||
# D. Naplózás ProcessLog-ba
|
||||
# D. Naplózás ProcessLog-ba (JAVÍTOTT RÉSZ)
|
||||
process_log = ProcessLog(
|
||||
process_name="Daily-Financial-Maintenance",
|
||||
status="COMPLETED" if not stats["errors"] else "PARTIAL",
|
||||
details=stats,
|
||||
executed_at=datetime.utcnow()
|
||||
items_processed=stats["vouchers_expired"] + stats["withdrawals_rejected"] + stats["users_downgraded"],
|
||||
items_failed=len(stats["errors"]),
|
||||
end_time=datetime.utcnow(),
|
||||
details={
|
||||
"status": "COMPLETED" if not stats["errors"] else "PARTIAL",
|
||||
**stats
|
||||
}
|
||||
)
|
||||
db.add(process_log)
|
||||
await db.commit()
|
||||
@@ -166,12 +170,17 @@ async def daily_financial_maintenance() -> None:
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Daily financial maintenance failed: {e}", exc_info=True)
|
||||
# Hiba esetén is naplózzuk
|
||||
# Hiba esetén is naplózzuk a modellnek megfelelő mezőkkel
|
||||
process_log = ProcessLog(
|
||||
process_name="Daily-Financial-Maintenance",
|
||||
status="FAILED",
|
||||
details={"error": str(e), **stats},
|
||||
executed_at=datetime.utcnow()
|
||||
items_processed=0,
|
||||
items_failed=1,
|
||||
end_time=datetime.utcnow(),
|
||||
details={
|
||||
"status": "FAILED",
|
||||
"error": str(e),
|
||||
**stats
|
||||
}
|
||||
)
|
||||
db.add(process_log)
|
||||
await db.commit()
|
||||
|
||||
Reference in New Issue
Block a user