Code indexing in gitaly is broken and leads to code not being visible to the user. We work on the issue with highest priority.

Skip to content
Snippets Groups Projects
Commit 530c9efa authored by GotthardG's avatar GotthardG
Browse files

retrieve pucks that are in the tell dewar

parent 6c88ff96
No related branches found
No related tags found
No related merge requests found
...@@ -132,10 +132,6 @@ async def scan_dewar(event_data: LogisticsEventCreate, db: Session = Depends(get ...@@ -132,10 +132,6 @@ async def scan_dewar(event_data: LogisticsEventCreate, db: Session = Depends(get
return {"message": "Status updated successfully"} return {"message": "Status updated successfully"}
@router.get("/slots", response_model=List[SlotSchema]) @router.get("/slots", response_model=List[SlotSchema])
async def get_all_slots(db: Session = Depends(get_db)): async def get_all_slots(db: Session = Depends(get_db)):
slots = db.query(SlotModel).options(joinedload(SlotModel.dewar)).all() slots = db.query(SlotModel).options(joinedload(SlotModel.dewar)).all()
......
...@@ -18,6 +18,55 @@ async def get_pucks(db: Session = Depends(get_db)): ...@@ -18,6 +18,55 @@ async def get_pucks(db: Session = Depends(get_db)):
return db.query(PuckModel).all() return db.query(PuckModel).all()
@router.get("/with-tell-position", response_model=List[dict])
async def get_pucks_with_tell_position(db: Session = Depends(get_db)):
"""
Retrieve all pucks with a `tell_position` set (not null) and their associated samples.
"""
# Query all pucks that have an event with a non-null tell_position
pucks = (
db.query(PuckModel)
.join(PuckEventModel, PuckModel.id == PuckEventModel.puck_id)
.filter(PuckEventModel.tell_position.isnot(None))
.all()
)
logger.info(f"Pucks with tell position: {pucks}")
if not pucks:
logger.info("No pucks with tell_position found.") # Log for debugging
raise HTTPException(
status_code=404,
detail="No pucks with a `tell_position` found."
)
result = []
for puck in pucks:
# Get associated samples for the puck
samples = db.query(SampleModel).filter(SampleModel.puck_id == puck.id).all()
sample_data = [
{
"id": sample.id,
"sample_name": sample.sample_name,
"position": sample.position, # Updated field based on schema
}
for sample in samples
]
# Add puck and sample info to the result
result.append(
{
"id": puck.id,
"puck_name": puck.puck_name,
"puck_type": puck.puck_type,
"puck_location_in_dewar": puck.puck_location_in_dewar,
"dewar_id": puck.dewar_id,
"samples": sample_data, # Add associated samples
}
)
return result
@router.get("/{puck_id}", response_model=PuckSchema) @router.get("/{puck_id}", response_model=PuckSchema)
async def get_puck(puck_id: str, db: Session = Depends(get_db)): async def get_puck(puck_id: str, db: Session = Depends(get_db)):
puck = db.query(PuckModel).filter(PuckModel.id == puck_id).first() puck = db.query(PuckModel).filter(PuckModel.id == puck_id).first()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment