Skip to content

Commit

Permalink
fix get_order_by_id
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxim2121512 committed Dec 18, 2024
1 parent b9593cb commit 6a4f9ee
Showing 1 changed file with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from motor.motor_asyncio import AsyncIOMotorDatabase
from pymongo.errors import PyMongoError

from src.infrastructure.repo_implementations.helpers.id_mapper import str_to_objectId
from src.infrastructure.repo_implementations.helpers.id_mapper import str_to_objectId, objectId_to_str


class MongoOrderRepository(IOrderRepository):
Expand Down Expand Up @@ -64,9 +64,20 @@ async def get_order_by_id(self, order_id: str) -> Optional[OrderSummary]:
"type": 1, "description": 1}
).to_list(length=None)
tools_model = [ToolSummary(**tool) for tool in tools]
order["tools"] = tools_model

print(order)
return OrderSummary(**order)
return OrderSummary(
id=objectId_to_str(order["_id"]),
price=order["price"],
tools=tools,
start_leasing=order["start_leasing"],
end_leasing=order["end_leasing"],
delivery_type=order["delivery_type"],
delivery_state=order["delivery_state"],
payment_type=order["payment_type"],
payment_state=order["payment_state"],
create_order_time=order["create_order_time"]
)
except PyMongoError:
raise DatabaseError()

Expand Down

0 comments on commit 6a4f9ee

Please sign in to comment.