Skip to content

Commit

Permalink
Bugfix to ensure links are created where an object has >1 class. Wrap…
Browse files Browse the repository at this point in the history
… call to objects with list() to prevent generator being consumed on first iteration of for loop (#183)
  • Loading branch information
recalcitrantsupplant authored Nov 28, 2023
1 parent 6135c69 commit 4585cbb
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions prez/services/model_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,14 @@ async def get_classes(
_, r = await repo.send_queries([], [(uri, q)])
tabular_result = r[0] # should only be one result - only one query sent
if endpoint != URIRef("https://prez.dev/endpoint/object"):
endpoint_classes = endpoints_graph_cache.objects(
endpoint_classes = list(endpoints_graph_cache.objects(
subject=endpoint, predicate=URIRef("https://prez.dev/ont/deliversClasses")
)
))
object_classes_delivered_by_endpoint = []
for c in tabular_result[1]:
if URIRef(c["class"]["value"]) in endpoint_classes:
object_classes_delivered_by_endpoint.append(c["class"]["value"])
object_classes_delivered_by_endpoint.append(URIRef(c["class"]["value"]))
classes = frozenset(object_classes_delivered_by_endpoint)
else:
classes = frozenset([c["class"]["value"] for c in tabular_result[1]])
# add profiles classes
# profiles_classes = profiles_graph_cache.query(q)
return classes

0 comments on commit 4585cbb

Please sign in to comment.