-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
### Added - Pipeline column to the order table. - Order-Customer relationship
- Loading branch information
Showing
9 changed files
with
81 additions
and
19 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
alembic/versions/2024_01_25_d241d8c493fb_add_pipeline_to_order.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
"""Add pipeline to order | ||
Revision ID: d241d8c493fb | ||
Revises: de0f5b78dca4 | ||
Create Date: 2024-01-25 16:18:35.740780 | ||
""" | ||
import sqlalchemy as sa | ||
|
||
from alembic import op | ||
from cg.constants import Pipeline | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "d241d8c493fb" | ||
down_revision = "de0f5b78dca4" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
op.add_column( | ||
table_name="order", | ||
column=sa.Column("workflow", sa.Enum(*tuple(Pipeline)), nullable=False), | ||
) | ||
|
||
|
||
def downgrade(): | ||
op.drop_column( | ||
table_name="order", | ||
column_name="workflow", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,17 @@ | ||
from cg.server.dto.orders.orders_response import Order as PydanticOrder | ||
from cg.server.dto.orders.orders_response import Order, OrdersResponse | ||
from cg.store.models import Order as DatabaseOrder | ||
|
||
|
||
def parse_order(order: DatabaseOrder) -> PydanticOrder: | ||
return PydanticOrder( | ||
customer_id=order.customer_id, ticket_id=order.ticket_id, order_date=order.order_date | ||
def parse_order(order: DatabaseOrder) -> Order: | ||
return Order( | ||
customer_id=order.customer.internal_id, | ||
ticket_id=order.ticket_id, | ||
order_date=str(order.order_date.date()), | ||
order_id=order.id, | ||
workflow=order.workflow, | ||
) | ||
|
||
|
||
def create_orders_response(database_orders: list[DatabaseOrder]) -> OrdersResponse: | ||
parsed_database_orders: list[Order] = [parse_order(order) for order in database_orders] | ||
return OrdersResponse(orders=parsed_database_orders) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters