Skip to content

Commit

Permalink
#31: Change format of accepted query strings
Browse files Browse the repository at this point in the history
  • Loading branch information
keiranjprice101 committed Aug 13, 2019
1 parent 2f59010 commit 63aa305
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions common/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,14 @@ def is_valid_json(string):


def get_filters_from_query_string():
log.info( "Getting filters from query string")
filters = request.args.getlist("filter")
return list(map(lambda x: json.loads(x), filters))
"""
Gets a list of filters from the query_strings arg,value pairs.
:example: /datafiles?limit=10&where={"DATASET_ID":2} -> [{"limit":10}, {"where":{"DATASET_ID":10}}]
:return: The list of filters
"""
log.info(" Getting filters from query string")
filters = []
for arg in request.args:
for value in request.args.getlist(arg):
filters.append({arg: json.loads(value)})
return filters

0 comments on commit 63aa305

Please sign in to comment.