Add sorting
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from typing import Annotated
|
||||
from typing import Annotated, Literal
|
||||
|
||||
from fastapi import APIRouter, Depends
|
||||
|
||||
@@ -48,10 +48,14 @@ async def create_house(
|
||||
@router.get("")
|
||||
async def get_all_houses(
|
||||
house_repository: Annotated[HouseRepository, Depends()],
|
||||
order_by: Literal["PRICE"] = "PRICE",
|
||||
sort_order: Literal["ASC", "DESC"] = "DESC",
|
||||
limit: int = 100,
|
||||
offset: int = 0,
|
||||
) -> HousesListResponse:
|
||||
all_houses = await house_repository.get_all(offset=offset, limit=limit)
|
||||
all_houses = await house_repository.get_all(
|
||||
offset=offset, limit=limit, order_by=order_by, sort_order=sort_order
|
||||
)
|
||||
|
||||
house_responses = [
|
||||
HouseResponse(
|
||||
@@ -64,6 +68,5 @@ async def get_all_houses(
|
||||
)
|
||||
for house in all_houses
|
||||
]
|
||||
print(house_responses)
|
||||
|
||||
return HousesListResponse(houses=house_responses)
|
||||
|
||||
Reference in New Issue
Block a user