Refactor set_tell_positions logic with updated rules.
Revised the set_tell_positions endpoint to handle updated business rules for puck positioning. Improved event handling to ensure proper nullification, updates, and removal of tell_positions based on the provided payload. Enhanced query performance and normalized puck name processing for consistency.
This commit is contained in:
parent
0fdd5e54b7
commit
a9cb7a41b0
@ -338,6 +338,7 @@ async def get_pucks_by_slot(slot_identifier: str, db: Session = Depends(get_db))
|
|||||||
)
|
)
|
||||||
|
|
||||||
dewar_ids = [dewar.id for dewar in dewars]
|
dewar_ids = [dewar.id for dewar in dewars]
|
||||||
|
dewar_map = {dewar.id: dewar.dewar_name for dewar in dewars}
|
||||||
|
|
||||||
# Subquery to fetch the latest tell_position for each puck
|
# Subquery to fetch the latest tell_position for each puck
|
||||||
subquery = (
|
subquery = (
|
||||||
@ -380,6 +381,8 @@ async def get_pucks_by_slot(slot_identifier: str, db: Session = Depends(get_db))
|
|||||||
f" Tell Position: {tell_position}"
|
f" Tell Position: {tell_position}"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
dewar_name = dewar_map.get(puck.dewar_id, "Unknown")
|
||||||
|
|
||||||
# Prepare the PuckWithTellPosition instance
|
# Prepare the PuckWithTellPosition instance
|
||||||
results.append(
|
results.append(
|
||||||
PuckWithTellPosition(
|
PuckWithTellPosition(
|
||||||
@ -390,6 +393,7 @@ async def get_pucks_by_slot(slot_identifier: str, db: Session = Depends(get_db))
|
|||||||
if puck.puck_location_in_dewar
|
if puck.puck_location_in_dewar
|
||||||
else None,
|
else None,
|
||||||
dewar_id=puck.dewar_id,
|
dewar_id=puck.dewar_id,
|
||||||
|
dewar_name=dewar_name,
|
||||||
tell_position=tell_position, # Latest tell_position from subquery
|
tell_position=tell_position, # Latest tell_position from subquery
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -478,7 +478,7 @@ class Puck(BaseModel):
|
|||||||
puck_location_in_dewar: int
|
puck_location_in_dewar: int
|
||||||
dewar_id: int
|
dewar_id: int
|
||||||
events: List[PuckEvent] = []
|
events: List[PuckEvent] = []
|
||||||
samples: List[Sample] = [] # List of samples within this puck
|
samples: List[Sample] = []
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
from_attributes = True
|
from_attributes = True
|
||||||
@ -645,6 +645,8 @@ class PuckWithTellPosition(BaseModel):
|
|||||||
puck_type: str
|
puck_type: str
|
||||||
puck_location_in_dewar: Optional[str]
|
puck_location_in_dewar: Optional[str]
|
||||||
dewar_id: int
|
dewar_id: int
|
||||||
|
dewar_name: str
|
||||||
|
user: str = "e16371"
|
||||||
samples: Optional[List[Sample]] = None
|
samples: Optional[List[Sample]] = None
|
||||||
tell_position: Optional[str]
|
tell_position: Optional[str]
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "aareDB"
|
name = "aareDB"
|
||||||
version = "0.1.0a13"
|
version = "0.1.0a14"
|
||||||
description = "Backend for next gen sample management system"
|
description = "Backend for next gen sample management system"
|
||||||
authors = [{name = "Guillaume Gotthard", email = "guillaume.gotthard@psi.ch"}]
|
authors = [{name = "Guillaume Gotthard", email = "guillaume.gotthard@psi.ch"}]
|
||||||
license = {text = "MIT"}
|
license = {text = "MIT"}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user