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.
This commit is contained in:
@@ -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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user