Fix formatting with black

This commit is contained in:
GotthardG
2024-12-16 10:41:56 +01:00
parent 57763970f9
commit a0be71bdfe
26 changed files with 1657 additions and 645 deletions

View File

@@ -2,7 +2,11 @@ from fastapi import APIRouter, HTTPException, status, Depends
from sqlalchemy.orm import Session
from typing import List
from app.schemas import Puck as PuckSchema, Sample as SampleSchema, SampleEventCreate
from app.models import Puck as PuckModel, Sample as SampleModel, SampleEvent as SampleEventModel
from app.models import (
Puck as PuckModel,
Sample as SampleModel,
SampleEvent as SampleEventModel,
)
from app.dependencies import get_db
import logging
@@ -18,10 +22,15 @@ async def get_samples_with_events(puck_id: str, db: Session = Depends(get_db)):
samples = db.query(SampleModel).filter(SampleModel.puck_id == puck_id).all()
for sample in samples:
sample.events = db.query(SampleEventModel).filter(SampleEventModel.sample_id == sample.id).all()
sample.events = (
db.query(SampleEventModel)
.filter(SampleEventModel.sample_id == sample.id)
.all()
)
return samples
@router.get("/pucks-samples", response_model=List[PuckSchema])
async def get_all_pucks_with_samples_and_events(db: Session = Depends(get_db)):
logging.info("Fetching all pucks with samples and events")
@@ -32,5 +41,7 @@ async def get_all_pucks_with_samples_and_events(db: Session = Depends(get_db)):
logging.info(f"Puck ID: {puck.id}, Name: {puck.puck_name}")
if not pucks:
raise HTTPException(status_code=404, detail="No pucks found in the database") # More descriptive
raise HTTPException(
status_code=404, detail="No pucks found in the database"
) # More descriptive
return pucks