Skip to content

Commit

Permalink
Address some review comments #87
Browse files Browse the repository at this point in the history
  • Loading branch information
joelvdavies committed Oct 24, 2023
1 parent d9012d6 commit 0f7f550
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,14 @@ def get_catalogue_category_breadcrumbs(
try:
return catalogue_category_service.get_breadcrumbs(catalogue_category_id)
except (MissingRecordError, InvalidObjectIdError) as exc:
raise HTTPException(
status_code=status.HTTP_404_NOT_FOUND, detail="Catalogue category with such ID was not found"
) from exc
message = "Catalogue category with such ID was not found"
logger.exception(message)
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail=message) from exc
except DatabaseIntegrityError as exc:
logger.exception("Unable to obtain breadcrumbs due to a database issue")
raise HTTPException(
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
detail="Unable to obtain breadcrumbs due to a database issue",
detail="Unable to obtain breadcrumbs",
) from exc


Expand Down
7 changes: 5 additions & 2 deletions inventory_management_system_api/routers/v1/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,14 @@ def get_system_breadcrumbs(
try:
return system_service.get_breadcrumbs(system_id)
except (MissingRecordError, InvalidObjectIdError) as exc:
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="System with such ID was not found") from exc
message = "System with such ID was not found"
logger.exception(message)
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail=message) from exc
except DatabaseIntegrityError as exc:
logger.exception("Unable to obtain breadcrumbs due to a database issue")
raise HTTPException(
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
detail="Unable to obtain breadcrumbs due to a database issue",
detail="Unable to obtain breadcrumbs",
) from exc
# pylint: enable=duplicate-code

Expand Down
9 changes: 5 additions & 4 deletions inventory_management_system_api/schemas/breadcrumbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ class BreadcrumbsGetSchema(BaseModel):
"""

trail: list[tuple[str, str]] = Field(
description="List of tuples representing the trail of parents for the entity in the form (entity_id, name). "
"Where the 'entity_id' is a string giving the ID of the entity and 'name' is a string representation of how "
f"it should be displayed in the breadcrumb. A maximum number of ${BREADCRUMBS_TRAIL_MAX_LENGTH} are returned."
description="List of two-element lists representing the trail of parents for the entity in the form "
"[entity_id, name]. Where the 'entity_id' is a string giving the ID of the entity and 'name' is a string "
"representation of how it should be displayed in the breadcrumb. A maximum number of "
f"{BREADCRUMBS_TRAIL_MAX_LENGTH} are returned."
)
full_trail: bool = Field(
description="Whether the entire parent hierarchy is reflected in the returned 'trail'. Will be False "
f"if the entity has more than ${BREADCRUMBS_TRAIL_MAX_LENGTH - 1} parents above it."
f"if the entity has more than {BREADCRUMBS_TRAIL_MAX_LENGTH - 1} parents above it."
)

0 comments on commit 0f7f550

Please sign in to comment.