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,
|
async def get_recent_payment_logs_with_user(session: AsyncSession,
|
||||||
limit: int = 20,
|
limit: int = 20,
|
||||||
offset: int = 0) -> List[Payment]:
|
offset: int = 0) -> List[Payment]:
|
||||||
stmt = (select(Payment).options(selectinload(Payment.user)).order_by(
|
stmt = (select(Payment).options(selectinload(Payment.user))
|
||||||
Payment.created_at.desc()).limit(limit).offset(offset))
|
.where(Payment.status == 'succeeded')
|
||||||
|
.order_by(Payment.created_at.desc())
|
||||||
|
.limit(limit).offset(offset))
|
||||||
result = await session.execute(stmt)
|
result = await session.execute(stmt)
|
||||||
return result.scalars().all()
|
return result.scalars().all()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user