Skip to content

Commit

Permalink
fix: wrong search count for some searches across nested properties
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlougheed committed Oct 29, 2024
1 parent 51de9e8 commit 2123496
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions chord_metadata_service/discovery/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,14 @@ def get_public_model_scoped_queryset(scope: ValidatedDiscoveryScope, mn: PublicM
filter_scope = "project"
value = scope.project_id
else:
return PUBLIC_MODEL_NAMES_TO_MODEL[mn].objects.all()
return PUBLIC_MODEL_NAMES_TO_MODEL[mn].objects.distinct()

filter_query = PUBLIC_MODEL_NAMES_TO_SCOPE_FILTERS[mn][filter_scope]["filter"]
prefetch = PUBLIC_MODEL_NAMES_TO_SCOPE_FILTERS[mn][filter_scope]["prefetch_related"]

return PUBLIC_MODEL_NAMES_TO_MODEL[mn].objects.prefetch_related(*prefetch).filter(**{filter_query: value})
return (
PUBLIC_MODEL_NAMES_TO_MODEL[mn].objects
.distinct()
.prefetch_related(*prefetch)
.filter(**{filter_query: value})
)

0 comments on commit 2123496

Please sign in to comment.