Skip to content

Commit

Permalink
add crud function to create order
Browse files Browse the repository at this point in the history
  • Loading branch information
diitaz93 committed Dec 17, 2024
1 parent 39b2251 commit 1c3e435
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,7 @@ def _create_db_order(self, order: MicrobialFastqOrder) -> Order:
customer: Customer = self.status_db.get_customer_by_internal_id(
customer_internal_id=order.customer
)
return Order(
customer=customer,
order_date=datetime.now(),
ticket_id=int(ticket_id),
)
return self.status_db.add_order(customer=customer, ticket_id=ticket_id)

def _create_db_sample(
self,
Expand Down
14 changes: 5 additions & 9 deletions cg/store/crud/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,17 +398,13 @@ def add_organism(
**kwargs,
)

def add_order(self, order_data: OrderIn):
customer: Customer = self.get_customer_by_internal_id(order_data.customer)
workflow: str = order_data.samples[0].data_analysis
def add_order(self, customer: Customer, ticket_id: str | int) -> Order:
"""Build a new Order record."""
order = Order(
customer_id=customer.id,
ticket_id=order_data.ticket,
workflow=workflow,
customer=customer,
order_date=datetime.now(),
ticket_id=int(ticket_id),
)
session: Session = get_session()
session.add(order)
session.commit()
return order

@staticmethod
Expand Down

0 comments on commit 1c3e435

Please sign in to comment.