Skip to content

Commit

Permalink
feat: added query get_operation_order
Browse files Browse the repository at this point in the history
  • Loading branch information
SteBaum committed Jan 22, 2024
1 parent ed9b865 commit ff7d3eb
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tdp/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,3 +504,31 @@ def get_operation_records(
raise Exception(
f"Operation {operation_name} does not exist in deployment {deployment_id}."
) from e


def get_operation_order(
session: Session, deployment_id: int, operation_order: int
) -> OperationModel:
"""Get an operation order.
Args:
session: The database session.
deployment_id: The deployment ID.
operation_order: The operation order.
Returns:
The matching operation record.
Raises:
NoResultFound: If the operation order does not exist.
"""
try:
return (
session.query(OperationModel)
.filter_by(deployment_id=deployment_id, operation_order=operation_order)
.one()
)
except NoResultFound as e:
raise Exception(
f"Operation {operation_order} does not exist in deployment {deployment_id}."
) from e

0 comments on commit ff7d3eb

Please sign in to comment.