Skip to content

Commit

Permalink
chore: docstring for get_public_model_scoped_queryset(...)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlougheed committed Oct 30, 2024
1 parent 91ce645 commit 0798195
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions chord_metadata_service/discovery/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,19 @@ def get_discovery_field_set_permissions(


def get_public_model_scoped_queryset(scope: ValidatedDiscoveryScope, mn: PublicModelName) -> QuerySet:
"""
Discovery models can be scoped to either a project or dataset; for downstream filtering, we need to pre-scope the
model queryset to the project/dataset being queried.
Since downstream filtering may be applied to (possibly deeply)nested fields/models (e.g., biosamples, experiments),
we use `.distinct()` instead of `.all()`. Otherwise, there may be multiple instances of the same top-level object
(individual especially, which has this deep nesting) for each nested instance, for example, in the case of multiple
experiments for a biosample for an individual.
:param scope: The scope to filter the queryset to.
:param mn: The discovery/"public" model name for
"""

filter_scope: PublicScopeFilterKeys
if scope.dataset_id:
filter_scope = "dataset"
Expand Down

0 comments on commit 0798195

Please sign in to comment.