Skip to content

Commit

Permalink
#141: Change function to fetch distinct attributes
Browse files Browse the repository at this point in the history
- I haven't deleted the original function yet, but it's very likely I will at the end of this work as there are no other calls to that function
  • Loading branch information
MRichards99 committed Apr 12, 2021
1 parent abb31bd commit 42dea33
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion datagateway_api/common/icat/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def execute_query(self, client, return_json_formattable=False):
if self.query.aggregate == "DISTINCT" and not count_query:
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()
distinct_attributes = self.get_distinct_attributes()
if distinct_attributes != []:
mapped_distinct_fields = self.map_distinct_attributes_to_entity_names(
distinct_attributes, flat_query_includes,
Expand Down Expand Up @@ -121,6 +121,9 @@ def execute_query(self, client, return_json_formattable=False):
log.info("Query results will be returned as ICAT entities")
return query_result

def get_distinct_attributes(self):
return self.query.attributes

def iterate_query_conditions_for_distinctiveness(self):
distinct_attributes = []
for attribute_name, where_statement in self.query.conditions.items():
Expand Down

0 comments on commit 42dea33

Please sign in to comment.