code quality fixes
This commit is contained in:
@@ -26,12 +26,8 @@ router = APIRouter(prefix="/api/sleep", tags=["sleep"])
|
||||
def create_sleep(
|
||||
request: CreateSleepRequest,
|
||||
user_id: Annotated[int, Depends(verify_token)],
|
||||
sleep_repo: Annotated[
|
||||
SleepRepositoryInterface, Depends(get_sleep_repository)
|
||||
],
|
||||
child_repo: Annotated[
|
||||
ChildRepositoryInterface, Depends(get_child_repository)
|
||||
],
|
||||
sleep_repo: Annotated[SleepRepositoryInterface, Depends(get_sleep_repository)],
|
||||
child_repo: Annotated[ChildRepositoryInterface, Depends(get_child_repository)],
|
||||
) -> SleepResponse:
|
||||
"""Create a new sleep log entry."""
|
||||
# Verify the child belongs to the authenticated user
|
||||
@@ -48,12 +44,8 @@ def create_sleep(
|
||||
@router.get("/active", response_model=SleepResponse | None)
|
||||
def get_active_sleep(
|
||||
user_id: Annotated[int, Depends(verify_token)],
|
||||
sleep_repo: Annotated[
|
||||
SleepRepositoryInterface, Depends(get_sleep_repository)
|
||||
],
|
||||
child_repo: Annotated[
|
||||
ChildRepositoryInterface, Depends(get_child_repository)
|
||||
],
|
||||
sleep_repo: Annotated[SleepRepositoryInterface, Depends(get_sleep_repository)],
|
||||
child_repo: Annotated[ChildRepositoryInterface, Depends(get_child_repository)],
|
||||
) -> SleepResponse | None:
|
||||
"""Get the current active sleep (where end_time is null) for the user."""
|
||||
sleeps = sleep_repo.get_by_user_id(user_id)
|
||||
@@ -74,9 +66,7 @@ def get_active_sleep(
|
||||
@router.get("", response_model=list[SleepResponse])
|
||||
def get_user_sleeps(
|
||||
user_id: Annotated[int, Depends(verify_token)],
|
||||
sleep_repo: Annotated[
|
||||
SleepRepositoryInterface, Depends(get_sleep_repository)
|
||||
],
|
||||
sleep_repo: Annotated[SleepRepositoryInterface, Depends(get_sleep_repository)],
|
||||
) -> list[SleepResponse]:
|
||||
"""Get all sleep logs for the authenticated user's children."""
|
||||
sleeps = sleep_repo.get_by_user_id(user_id)
|
||||
@@ -87,12 +77,8 @@ def get_user_sleeps(
|
||||
def get_sleep(
|
||||
sleep_id: int,
|
||||
user_id: Annotated[int, Depends(verify_token)],
|
||||
sleep_repo: Annotated[
|
||||
SleepRepositoryInterface, Depends(get_sleep_repository)
|
||||
],
|
||||
child_repo: Annotated[
|
||||
ChildRepositoryInterface, Depends(get_child_repository)
|
||||
],
|
||||
sleep_repo: Annotated[SleepRepositoryInterface, Depends(get_sleep_repository)],
|
||||
child_repo: Annotated[ChildRepositoryInterface, Depends(get_child_repository)],
|
||||
) -> SleepResponse:
|
||||
"""Get a specific sleep log by ID."""
|
||||
sleep = sleep_repo.get_by_id(sleep_id)
|
||||
@@ -111,12 +97,8 @@ def update_sleep(
|
||||
sleep_id: int,
|
||||
request: UpdateSleepRequest,
|
||||
user_id: Annotated[int, Depends(verify_token)],
|
||||
sleep_repo: Annotated[
|
||||
SleepRepositoryInterface, Depends(get_sleep_repository)
|
||||
],
|
||||
child_repo: Annotated[
|
||||
ChildRepositoryInterface, Depends(get_child_repository)
|
||||
],
|
||||
sleep_repo: Annotated[SleepRepositoryInterface, Depends(get_sleep_repository)],
|
||||
child_repo: Annotated[ChildRepositoryInterface, Depends(get_child_repository)],
|
||||
) -> SleepResponse:
|
||||
"""Update an existing sleep log."""
|
||||
sleep = sleep_repo.get_by_id(sleep_id)
|
||||
@@ -142,12 +124,8 @@ def update_sleep(
|
||||
def delete_sleep(
|
||||
sleep_id: int,
|
||||
user_id: Annotated[int, Depends(verify_token)],
|
||||
sleep_repo: Annotated[
|
||||
SleepRepositoryInterface, Depends(get_sleep_repository)
|
||||
],
|
||||
child_repo: Annotated[
|
||||
ChildRepositoryInterface, Depends(get_child_repository)
|
||||
],
|
||||
sleep_repo: Annotated[SleepRepositoryInterface, Depends(get_sleep_repository)],
|
||||
child_repo: Annotated[ChildRepositoryInterface, Depends(get_child_repository)],
|
||||
) -> None:
|
||||
"""Delete a sleep log."""
|
||||
sleep = sleep_repo.get_by_id(sleep_id)
|
||||
|
||||
Reference in New Issue
Block a user