From 8d1dba20c01b1f7669f6427775e1448bdfdf7fec Mon Sep 17 00:00:00 2001 From: Matthew Richards Date: Wed, 14 Oct 2020 10:40:01 +0000 Subject: [PATCH] #146: Apply count query flag logic to second ISIS endpoint - It should be noted that the affected endpoint doesn't currently do anything --- common/icat/helpers.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/common/icat/helpers.py b/common/icat/helpers.py index 8d44841a..e6fb5edb 100644 --- a/common/icat/helpers.py +++ b/common/icat/helpers.py @@ -538,7 +538,7 @@ def get_facility_cycles_for_instrument_count(client, instrument_id, filters): def get_investigations_for_instrument_in_facility_cycle( - client, instrument_id, facilitycycle_id, filters + client, instrument_id, facilitycycle_id, filters, count_query=False ): """ Given Instrument and Facility Cycle IDs, get investigations that use the given @@ -552,9 +552,16 @@ def get_investigations_for_instrument_in_facility_cycle( :type facilitycycle_id: :class:`int` :param filters: The list of filters to be applied to the request :type filters: List of specific implementations :class:`QueryFilter` + :param count_query: Flag to determine if the query in this function should be used + as a count query. Used for + `get_investigations_for_instrument_in_facility_cycle_count()` + :type count_query: :class:`bool` :return: A list of Investigations that match the query """ - pass + query_aggregate = "COUNT" if count_query else None + query = ICATQuery( + client, "Investigation", aggregate=query_aggregate, isis_endpoint=True + ) def get_investigations_for_instrument_in_facility_cycle_count( @@ -574,4 +581,6 @@ def get_investigations_for_instrument_in_facility_cycle_count( :type filters: List of specific implementations :class:`QueryFilter` :return: The number of Investigations that match the query """ - pass + return get_investigations_for_instrument_in_facility_cycle( + client, instrument_id, facilitycycle_id, filters, count_query=True + )[0]