mirror of
https://github.com/stijndcl/didier.git
synced 2026-04-07 23:55:46 +02:00
Parsing of schedules
This commit is contained in:
parent
8fea65e4ad
commit
14ccb42424
10 changed files with 228 additions and 20 deletions
|
|
@ -5,7 +5,7 @@ from sqlalchemy.ext.asyncio import AsyncSession
|
|||
|
||||
from database.schemas import UforaCourse, UforaCourseAlias
|
||||
|
||||
__all__ = ["get_all_courses", "get_course_by_name"]
|
||||
__all__ = ["get_all_courses", "get_course_by_code", "get_course_by_name"]
|
||||
|
||||
|
||||
async def get_all_courses(session: AsyncSession) -> list[UforaCourse]:
|
||||
|
|
@ -14,6 +14,12 @@ async def get_all_courses(session: AsyncSession) -> list[UforaCourse]:
|
|||
return list((await session.execute(statement)).scalars().all())
|
||||
|
||||
|
||||
async def get_course_by_code(session: AsyncSession, code: str) -> Optional[UforaCourse]:
|
||||
"""Try to find a course by its code"""
|
||||
statement = select(UforaCourse).where(UforaCourse.code == code)
|
||||
return (await session.execute(statement)).scalar_one_or_none()
|
||||
|
||||
|
||||
async def get_course_by_name(session: AsyncSession, query: str) -> Optional[UforaCourse]:
|
||||
"""Try to find a course by its name
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue