Skip to content

Commit

Permalink
#140: Add docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
MRichards99 committed Aug 19, 2020
1 parent aec81f1 commit 182d054
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
1 change: 1 addition & 0 deletions common/icat/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ def apply_filter(self, query):


class PythonICATOrderFilter(OrderFilter):
# Used to append the order tuples across all filters in a single request
result_order = []

def __init__(self, field, direction):
Expand Down
22 changes: 20 additions & 2 deletions common/icat/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,18 @@ def update_entity_by_id(client, table_name, id_, new_data):

def get_entity_with_filters(client, table_name, filters):
"""
TODO - Add docstring
Gets all the records of a given entity, based on the filters provided in the request
:param client: ICAT client containing an authenticated user
:type client: :class:`icat.client.Client`
:param table_name: Table name to extract which entity to use
:type table_name: :class:`str`
:param filters: The list of filters to be applied to the request
:type filters: List of specific implementations :class:`QueryFilter`
:return: The list of records of the given entity, using the filters to restrict the
result of the query
"""

selected_entity_name = get_python_icat_entity_name(client, table_name)
query = construct_icat_query(client, selected_entity_name)

Expand All @@ -381,7 +391,15 @@ def get_entity_with_filters(client, table_name, filters):

def manage_order_filters(filters):
"""
TODO - Add docstring
Checks if any order filters have been added to the request and resets the variable
used to manage which attribute(s) to use for sorting results.
A reset is required because Python ICAT overwrites (as opposed to appending to it)
the query's order list every time one is added to the query.
:param filters: The list of filters to be applied to the request
:type filters: List of specific implementations :class:`QueryFilter`
"""

if any(isinstance(filter, PythonICATOrderFilter) for filter in filters):
PythonICATOrderFilter.result_order = []

0 comments on commit 182d054

Please sign in to comment.