Skip to content

Commit

Permalink
make it a bit safer
Browse files Browse the repository at this point in the history
  • Loading branch information
leoschwarz committed Jul 22, 2024
1 parent fb536b5 commit 818532b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions bfabric/entities/core/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ def _client(self) -> Bfabric | None:

@classmethod
def find(cls, id: int, client: Bfabric) -> Self | None:
result = client.read(cls.ENDPOINT, obj={"id": id})
result = client.read(cls.ENDPOINT, obj={"id": int(id)})
return cls(result[0], client=client) if len(result) == 1 else None

@classmethod
def find_all(cls, ids: list[int], client: Bfabric) -> dict[int, Self]:
if len(ids) > 100:
# TODO use paginated read if more than 100 ids
raise NotImplementedError("Pagination not yet implemented here.")
result = client.read(cls.ENDPOINT, obj={"id": ids})
result = client.read(cls.ENDPOINT, obj={"id": [int(id) for id in ids]})
results = {x["id"]: cls(x, client=client) for x in result}
if len(results) != len(ids):
logger.warning(f"Only found {len(results)} out of {len(ids)}.")
Expand Down

0 comments on commit 818532b

Please sign in to comment.