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:
@ -99,7 +99,12 @@ async def get_last_sample_event(sample_id: int, db: Session = Depends(get_db)):
|
|||||||
if not last_event:
|
if not last_event:
|
||||||
raise HTTPException(status_code=404, detail="No events found for the sample")
|
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")
|
@router.post("/samples/{sample_id}/upload-images")
|
||||||
|
Reference in New Issue
Block a user