This commit is contained in:
2026-06-16 18:41:53 +05:30
parent 0f591b666b
commit d912053368

View File

@@ -69,7 +69,7 @@ def list_parents(limit: int = 20, offset: int = 0):
Paginated response with ``total`` and ``items``. Paginated response with ``total`` and ``items``.
""" """
items = _list_parents() items = _list_parents()
return {"total": len(items), "items": items[offset:offset + limit]} return {"total": len(items), "items": items[offset:offset + limit] if limit else items[offset:]}
def create_parent(payload: ParentCreate, response: Response): def create_parent(payload: ParentCreate, response: Response):
@@ -168,7 +168,7 @@ def delete_parent(id: int, response: Response):
def list_vets(limit: int = 20, offset: int = 0): def list_vets(limit: int = 20, offset: int = 0):
"""List vets (paginated).""" """List vets (paginated)."""
items = _list_vets() items = _list_vets()
return {"total": len(items), "items": items[offset:offset + limit]} return {"total": len(items), "items": items[offset:offset + limit] if limit else items[offset:]}
def create_vet(payload: VetCreate, response: Response): def create_vet(payload: VetCreate, response: Response):
@@ -259,7 +259,7 @@ def delete_treatment(id: int, response: Response):
def list_pets(limit: int = 20, offset: int = 0): def list_pets(limit: int = 20, offset: int = 0):
"""List pets (paginated).""" """List pets (paginated)."""
items = _list_pets() items = _list_pets()
return {"total": len(items), "items": items[offset:offset + limit]} return {"total": len(items), "items": items[offset:offset + limit] if limit else items[offset:]}
def create_pet(payload: PetCreate, response: Response): def create_pet(payload: PetCreate, response: Response):
@@ -330,7 +330,7 @@ def list_appointments(limit: int = 20, offset: int = 0, date: str = None, vet: i
if pet is not None: if pet is not None:
items = [a for a in items if a.pet.id == pet] items = [a for a in items if a.pet.id == pet]
return {"total": len(items), "items": items[offset:offset + limit]} return {"total": len(items), "items": items[offset:offset + limit] if limit else items[offset:]}
def create_appointment(payload: AppointmentCreate, response: Response): def create_appointment(payload: AppointmentCreate, response: Response):