Skip to content

Commit

Permalink
#114: Allow distinct filters to correct apply to ISIS endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
MRichards99 committed Oct 19, 2020
1 parent 4aa1331 commit 5e19893
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions common/icat/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,19 +104,21 @@ def execute_query(self, client, return_json_formattable=False):
if (
self.query.aggregate == "DISTINCT"
and not count_query
and not self.isis_endpoint
#and not self.isis_endpoint
):
log.info("Extracting the distinct fields from query's conditions")
# Check query's conditions for the ones created by the distinct filter
distinct_attributes = self.iterate_query_conditions_for_distinctiveness()
mapped_distinct_fields = self.map_distinct_attributes_to_entity_names(
distinct_attributes, flat_query_includes
)
log.debug(
"Attribute names used in the distinct filter, mapped to the entity they"
" are a part of: %s",
mapped_distinct_fields,
)
log.debug(f"Distinct Attributes: {distinct_attributes}")
if distinct_attributes != []:
mapped_distinct_fields = self.map_distinct_attributes_to_entity_names(
distinct_attributes, flat_query_includes
)
log.debug(
"Attribute names used in the distinct filter, mapped to the entity they"
" are a part of: %s",
mapped_distinct_fields,
)

if return_json_formattable:
log.info("Query results will be returned in a JSON format")
Expand Down Expand Up @@ -276,8 +278,7 @@ def map_distinct_attributes_to_entity_names(self, distinct_fields, included_fiel
"""

# Mapping which entities have distinct fields
distinct_field_dict = {}
distinct_field_dict["base"] = []
distinct_field_dict = {"base": []}

for field in distinct_fields:
split_fields = field.split(".")
Expand Down

0 comments on commit 5e19893

Please sign in to comment.