Refactor dewar and sample handling; improve grid data binding
Updated Dewar and Sample schemas, added nested relationships, and adjusted API responses for better data handling. Simplified puck normalization, enhanced data grid logic in the frontend, and implemented a PUT endpoint for updating samples. Incremented backend version to 0.1.0a15 and added new HTTP request example.
This commit is contained in:
@ -34,8 +34,7 @@ def normalize_puck_name(name: str) -> str:
|
||||
"""
|
||||
Normalize a puck_name to remove special characters and ensure consistent formatting.
|
||||
"""
|
||||
name = str(name).strip().replace(" ", "_").upper()
|
||||
name = re.sub(r"[^A-Z0-9]", "", name) # Remove special characters
|
||||
name = re.sub(r"[^A-Z0-9]", "", name.upper()) # Remove special characters
|
||||
return name
|
||||
|
||||
|
||||
@ -50,22 +49,11 @@ async def set_tell_positions(
|
||||
):
|
||||
results = []
|
||||
|
||||
# Helper function to normalize puck names for database querying
|
||||
def normalize_puck_name(name: str) -> str:
|
||||
return str(name).strip().replace(" ", "_").upper()
|
||||
|
||||
if not pucks:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail="Payload cannot be empty. Provide at least one puck.",
|
||||
)
|
||||
|
||||
# Retrieve all pucks in the database with their most recent
|
||||
# `tell_position_set` event
|
||||
all_pucks_with_last_event = (
|
||||
db.query(PuckModel, PuckEventModel)
|
||||
.outerjoin(PuckEventModel, PuckEventModel.puck_id == PuckModel.id)
|
||||
.filter(PuckEventModel.event_type == "tell_position_set")
|
||||
.order_by(PuckEventModel.puck_id, PuckEventModel.timestamp.desc())
|
||||
.all()
|
||||
)
|
||||
|
Reference in New Issue
Block a user