From 63aa3054feebd8b051fee0c38093d6c0b6a1ee1f Mon Sep 17 00:00:00 2001 From: Keiran Price Date: Tue, 13 Aug 2019 07:36:41 +0100 Subject: [PATCH] #31: Change format of accepted query strings --- common/helpers.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/common/helpers.py b/common/helpers.py index 3650027d..eb9e0e6a 100644 --- a/common/helpers.py +++ b/common/helpers.py @@ -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