Skip to content

Commit

Permalink
fix alias for db Order
Browse files Browse the repository at this point in the history
  • Loading branch information
diitaz93 committed Jan 21, 2025
1 parent 5ed0239 commit 2d6512d
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions cg/services/orders/order_service/order_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from cg.services.orders.order_service.models import OrderQueryParams
from cg.services.orders.order_summary_service.dto.order_summary import OrderSummary
from cg.services.orders.order_summary_service.order_summary_service import OrderSummaryService
from cg.store.models import Order as DatabaseOrder
from cg.store.models import Order as DbOrder
from cg.store.store import Store


Expand All @@ -13,7 +13,7 @@ def __init__(self, store: Store, status_service: OrderSummaryService) -> None:
self.summary_service = status_service

def get_order(self, order_id: int) -> Order:
order: DatabaseOrder = self.store.get_order_by_id(order_id)
order: DbOrder = self.store.get_order_by_id(order_id)
summary: OrderSummary = self.summary_service.get_summary(order_id)
return self._create_order_response(order=order, summary=summary)

Expand All @@ -27,12 +27,12 @@ def get_orders(self, orders_request: OrdersRequest) -> OrdersResponse:
return self._create_orders_response(orders=orders, summaries=summaries, total=total_count)

def set_open(self, order_id: int, open: bool) -> Order:
order: DatabaseOrder = self.store.update_order_status(order_id=order_id, open=open)
order: DbOrder = self.store.update_order_status(order_id=order_id, open=open)
return self._create_order_response(order)

def update_is_open(self, order_id: int, delivered_analyses: int) -> None:
"""Update the is_open parameter of an order based on the number of delivered analyses."""
order: DatabaseOrder = self.store.get_order_by_id(order_id)
order: DbOrder = self.store.get_order_by_id(order_id)
case_count: int = len(order.cases)
if self._is_order_closed(case_count=case_count, delivered_analyses=delivered_analyses):
self.set_open(order_id=order_id, open=False)
Expand All @@ -52,7 +52,7 @@ def _get_order_query_params(orders_request: OrdersRequest) -> OrderQueryParams:
)

@staticmethod
def _create_order_response(order: DatabaseOrder, summary: OrderSummary | None = None) -> Order:
def _create_order_response(order: DbOrder, summary: OrderSummary | None = None) -> Order:
return Order(
customer_id=order.customer.internal_id,
ticket_id=order.ticket_id,
Expand All @@ -64,7 +64,7 @@ def _create_order_response(order: DatabaseOrder, summary: OrderSummary | None =
)

def _create_orders_response(
self, orders: list[DatabaseOrder], summaries: list[OrderSummary], total: int
self, orders: list[DbOrder], summaries: list[OrderSummary], total: int
) -> OrdersResponse:
orders: list[Order] = [self._create_order_response(order) for order in orders]
self._add_summaries(orders=orders, summaries=summaries)
Expand Down

0 comments on commit 2d6512d

Please sign in to comment.