Refactor response construction in sample endpoint.

Replaced direct return of `last_event` with an explicit construction of `SampleEventResponse`. This ensures clarity and better adherence to the response schema.
This commit is contained in:
GotthardG
2025-01-10 12:02:49 +01:00
parent c0db9c5bae
commit fa99e3fa63

View File

@ -99,7 +99,12 @@ async def get_last_sample_event(sample_id: int, db: Session = Depends(get_db)):
if not last_event:
raise HTTPException(status_code=404, detail="No events found for the sample")
return last_event # Response will automatically use the SampleEventResponse schema
return SampleEventResponse(
id=last_event.id,
sample_id=last_event.sample_id,
event_type=last_event.event_type,
timestamp=last_event.timestamp,
) # Response will automatically use the SampleEventResponse schema
@router.post("/samples/{sample_id}/upload-images")