Skip to content

Commit

Permalink
#146: Add skeleton to an ISIS endpoint
Browse files Browse the repository at this point in the history
- This endpoint does not work currently, there are issues with speech marks in WHERE filter of the startDate conditions and a DISTINCT aggregate needs to be added (with a flag in ICATQuery to mark an ISIS endpoint so the aggregate doesn't behave like a distinct filter - these are two different things)
  • Loading branch information
MRichards99 committed Oct 13, 2020
1 parent eb2382d commit b6333e9
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion common/icat/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,41 @@ def get_facility_cycles_for_instrument(client, instrument_id, filters):
:type filters: List of specific implementations :class:`QueryFilter`
:return: A list of Facility Cycles that match the query
"""
pass
# TODO - Add logging

query = ICATQuery(client, "FacilityCycle")

instrument_id_check = PythonICATWhereFilter(
"facility.instruments.id", instrument_id, "eq"
)
investigation_instrument_id_check = PythonICATWhereFilter(
"facility.instruments.investigationInstruments.instrument.id",
instrument_id,
"eq",
)
investigation_start_date_check = PythonICATWhereFilter(
"facility.investigations.startDate", "o.startDate", "gte"
)
investigation_end_date_check = PythonICATWhereFilter(
"facility.investigations.startDate", "o.endDate", "lte"
)

facility_cycle_filters = [
instrument_id_check,
investigation_instrument_id_check,
investigation_start_date_check,
investigation_end_date_check,
]
filters.extend(facility_cycle_filters)
filter_handler = FilterOrderHandler()
filter_handler.manage_icat_filters(filters, query.query)

data = query.execute_query(client, True)

if not data:
raise MissingRecordError("No results found")
else:
return data


def get_facility_cycles_for_instrument_count(client, instrument_id, filters):
Expand Down

0 comments on commit b6333e9

Please sign in to comment.