feat: products quantity and total price in deal schemas
This commit is contained in:
@ -26,7 +26,7 @@ class DealService(
|
||||
sorting: SortingSchema,
|
||||
*filters,
|
||||
) -> GetDealsResponse:
|
||||
deals, total_items = await self.repository.get_all(
|
||||
rows, total_items = await self.repository.get_all(
|
||||
pagination.page,
|
||||
pagination.items_per_page,
|
||||
sorting.field,
|
||||
@ -38,8 +38,17 @@ class DealService(
|
||||
if pagination.items_per_page:
|
||||
total_pages = math.ceil(total_items / pagination.items_per_page)
|
||||
|
||||
deals = [
|
||||
DealSchema(
|
||||
**deal.__dict__,
|
||||
products_quantity=products_quantity,
|
||||
total_price=total_price,
|
||||
)
|
||||
for deal, total_price, products_quantity in rows
|
||||
]
|
||||
|
||||
return GetDealsResponse(
|
||||
items=[DealSchema.model_validate(deal) for deal in deals],
|
||||
items=deals,
|
||||
pagination_info=PaginationInfoSchema(
|
||||
total_pages=total_pages, total_items=total_items
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user