main functions fix

This commit is contained in:
2025-11-15 20:03:49 +09:00
parent e0075d91b6
commit 3a25e6a4cb
18 changed files with 1779 additions and 75 deletions

View File

@@ -198,22 +198,28 @@ class LotteryService:
return result.scalar_one_or_none()
@staticmethod
async def get_active_lotteries(session: AsyncSession) -> List[Lottery]:
async def get_active_lotteries(session: AsyncSession, limit: Optional[int] = None) -> List[Lottery]:
"""Получить список активных розыгрышей"""
result = await session.execute(
select(Lottery)
.where(Lottery.is_active == True, Lottery.is_completed == False)
.order_by(Lottery.created_at.desc())
)
query = select(Lottery).where(
Lottery.is_active == True,
Lottery.is_completed == False
).order_by(Lottery.created_at.desc())
if limit:
query = query.limit(limit)
result = await session.execute(query)
return result.scalars().all()
@staticmethod
async def get_all_lotteries(session: AsyncSession) -> List[Lottery]:
async def get_all_lotteries(session: AsyncSession, limit: Optional[int] = None) -> List[Lottery]:
"""Получить список всех розыгрышей"""
result = await session.execute(
select(Lottery)
.order_by(Lottery.created_at.desc())
)
query = select(Lottery).order_by(Lottery.created_at.desc())
if limit:
query = query.limit(limit)
result = await session.execute(query)
return result.scalars().all()
@staticmethod