Skip to content

Commit

Permalink
#51: Make Querystring filter method return filter objects
Browse files Browse the repository at this point in the history
  • Loading branch information
keiranjprice101 committed Sep 11, 2019
1 parent 43638e2 commit 33ea947
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions common/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from flask_restful import reqparse
from sqlalchemy.exc import IntegrityError

from common.database_helpers import QueryFilterFactory
from common.exceptions import MissingRecordError, BadFilterError, AuthenticationError, BadRequestError
from common.models.db_models import SESSION
from common.session_manager import session_manager
Expand Down Expand Up @@ -109,13 +110,12 @@ def is_valid_json(string):

def get_filters_from_query_string():
"""
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}}]
Gets a list of filters from the query_strings arg,value pairs, and returns a list of QueryFilter Objects
: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)})
filters.append(QueryFilterFactory.get_query_filter({arg: json.loads(value)}))
return filters

0 comments on commit 33ea947

Please sign in to comment.