Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # crud
- async def get_all_events(session: AsyncSession):
- smt = select(Event).where(
- Event.is_closed == true(),
- Event.is_active == true()
- )
- result = await session.execute(smt)
- res = result.scalars().all()
- return res
- # services.EventService.get_events
- async def get_events(
- self,
- session: AsyncSession
- ) -> List[EventSchema]:
- res = await crud.get_all_events(session)
- return res
- # api
- @router.get(
- '/events',
- status_code=status.HTTP_200_OK,
- # response_model=List[EventSchema]
- )
- async def get_events(
- session: AsyncSession = Depends(get_session),
- service: EventService = Depends()
- ):
- res = await service.get_events(session)
- return res
Advertisement
Add Comment
Please, Sign In to add comment