From ed84060563bcd556380d18bab5334090f5d1290e Mon Sep 17 00:00:00 2001 From: GotthardG <51994228+GotthardG@users.noreply.github.com> Date: Wed, 11 Dec 2024 16:24:22 +0100 Subject: [PATCH] get puck events --- backend/app/routers/puck.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/backend/app/routers/puck.py b/backend/app/routers/puck.py index 24dcbc3..bbb32b6 100644 --- a/backend/app/routers/puck.py +++ b/backend/app/routers/puck.py @@ -126,4 +126,18 @@ async def get_last_tell_position(puck_id: str, db: Session = Depends(get_db)): "puck_id": puck_id, "tell_position": last_event.tell_position, "timestamp": last_event.timestamp, - } \ No newline at end of file + } + +@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 \ No newline at end of file