Skip to content
Snippets Groups Projects
Commit 624f37ec authored by Adrian Block's avatar Adrian Block
Browse files

Merge branch 'dev' into 'master'

Add threading lock

See merge request !4
parents d25e9e7b 90b5c613
No related branches found
No related tags found
1 merge request!4Add threading lock
Pipeline #
from threading import Lock
from typing import List
from cachetools import TTLCache, cached
......@@ -11,9 +12,11 @@ router = APIRouter()
@router.get("/search", response_model=List[schemas.CourseWithoutAppointments])
def list_and_search_courses_by_name(semesterId: int = Query(..., example=1),
def list_and_search_courses_by_name(
semesterId: int = Query(..., example=1),
title: str = Query(..., example="Systemsoftware und"),
broker: DatabaseBroker = Depends(get_database_broker)):
broker: DatabaseBroker = Depends(get_database_broker),
):
"""
List and search courses by name.
"""
......@@ -21,19 +24,31 @@ def list_and_search_courses_by_name(semesterId: int = Query(..., example=1),
@router.get("/all", response_model=List[schemas.CourseWithoutAppointments])
@cached(cache=TTLCache(maxsize=1024, ttl=600), key=lambda semesterId, broker: semesterId)
def list_all_courses_of_semester(semesterId: int = Query(..., example=1),
broker: DatabaseBroker = Depends(get_database_broker)):
@cached(
cache=TTLCache(maxsize=1024, ttl=600),
key=lambda semesterId, broker: semesterId,
lock=Lock(),
)
def list_all_courses_of_semester(
semesterId: int = Query(..., example=1),
broker: DatabaseBroker = Depends(get_database_broker),
):
"""
List all courses of a semester.
"""
return broker.get_all_courses_of_semester(semesterId)
@router.get("/{courseId}", response_model=schemas.Course, responses={404: {"model": schemas.DetailMessage}})
def retrieve_information_of_a_course(semesterId: int = Query(..., example=1),
@router.get(
"/{courseId}",
response_model=schemas.Course,
responses={404: {"model": schemas.DetailMessage}},
)
def retrieve_information_of_a_course(
semesterId: int = Query(..., example=1),
courseId: str = Path(..., example="L.079.05401"),
broker: DatabaseBroker = Depends(get_database_broker)):
broker: DatabaseBroker = Depends(get_database_broker),
):
"""
Querries course by id with all small groups and appointments.
"""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment