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 duplicate Places being returned for Expressions
(as a result of duplicate relations with Organisations).
  • Loading branch information
koeaw committed Sep 23, 2024
1 parent 90254d3 commit 42eb8be
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 42eb8be

Please sign in to comment.