From 194f1b9e49a6956626f032499f8f40a760e7aa21 Mon Sep 17 00:00:00 2001 From: machka-pasla Date: Thu, 7 Aug 2025 19:00:27 +0300 Subject: [PATCH] Enhance recent payment log retrieval to filter by succeeded status - Updated the `get_recent_payment_logs_with_user` function to include a filter for payments with a 'succeeded' status, improving the relevance of retrieved payment logs. - Adjusted the query structure for better readability and maintainability. --- db/dal/payment_dal.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/db/dal/payment_dal.py b/db/dal/payment_dal.py index 5187e58..5a93e6d 100644 --- a/db/dal/payment_dal.py +++ b/db/dal/payment_dal.py @@ -82,8 +82,10 @@ async def update_payment_status_by_db_id( async def get_recent_payment_logs_with_user(session: AsyncSession, limit: int = 20, offset: int = 0) -> List[Payment]: - stmt = (select(Payment).options(selectinload(Payment.user)).order_by( - Payment.created_at.desc()).limit(limit).offset(offset)) + stmt = (select(Payment).options(selectinload(Payment.user)) + .where(Payment.status == 'succeeded') + .order_by(Payment.created_at.desc()) + .limit(limit).offset(offset)) result = await session.execute(stmt) return result.scalars().all()