get puck events

This commit is contained in:
GotthardG 2024-12-11 16:24:22 +01:00
parent 9cd0d81dac
commit ed84060563

View File

@ -127,3 +127,17 @@ async def get_last_tell_position(puck_id: str, db: Session = Depends(get_db)):
"tell_position": last_event.tell_position, "tell_position": last_event.tell_position,
"timestamp": last_event.timestamp, "timestamp": last_event.timestamp,
} }
@router.get("/pucks/slot/{slot_id}", response_model=List[PuckSchema])
async def get_pucks_by_slot(slot_id: int, db: Session = Depends(get_db)):
"""
Retrieve all pucks for a given slot_id
"""
# Query for the pucks associated with the slot_id
pucks = db.query(PuckModel).filter(PuckModel.puck_location_in_dewar == slot_id).all()
# If no pucks found, return an empty list
if not pucks:
return []
return pucks