From 5e198933d4855dbd400d5445de7c24c37a8e4492 Mon Sep 17 00:00:00 2001 From: Matthew Richards Date: Mon, 19 Oct 2020 11:37:29 +0000 Subject: [PATCH] #114: Allow distinct filters to correct apply to ISIS endpoints --- common/icat/query.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/common/icat/query.py b/common/icat/query.py index bcec87da..b38bde85 100644 --- a/common/icat/query.py +++ b/common/icat/query.py @@ -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") @@ -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(".")