Skip to content

Commit

Permalink
fix(api): return distinct places
Browse files Browse the repository at this point in the history
Set expression_places distinct() for WorkPreviewViewSet
for consistency with WorkDetailViewSet. Prevents duplication
of places due to more than one publisher being (incorrectly)
set.
  • Loading branch information
koeaw committed Sep 23, 2024
1 parent 4186744 commit 5ea5106
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions apis_ontology/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,14 @@ def get_queryset(self):
triple_set_from_subj__prop__name_reverse__in=["has publisher"],
).values("name")

expression_places = Place.objects.filter(
triple_set_from_obj__subj_id=OuterRef("pk"),
triple_set_from_obj__prop__name_forward__in=["is published in"],
).values_list("name")
expression_places = (
Place.objects.filter(
triple_set_from_obj__subj_id=OuterRef("pk"),
triple_set_from_obj__prop__name_forward__in=["is published in"],
)
.distinct()
.values_list("name")
)

related_expressions = (
Expression.objects.filter(
Expand Down

0 comments on commit 5ea5106

Please sign in to comment.