Skip to content

Commit

Permalink
Merge pull request #315 from EGA-archive/develop
Browse files Browse the repository at this point in the history
genomicVariations get request parameter filters fixed
  • Loading branch information
costero-e authored Apr 12, 2024
2 parents 5ae04ac + 80c67c2 commit 369a0f5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
12 changes: 9 additions & 3 deletions beacon/db/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,8 +411,10 @@ def apply_ontology_filter(query: dict, filter: OntologyFilter, collection: str,


scope = filter.scope
if scope is None:
if scope is None and collection != 'g_variants':
scope = collection[0:-1]
elif scope is None:
scope = 'genomicVariation'
LOG.debug(scope)
is_filter_id_required = True
# Search similar
Expand Down Expand Up @@ -653,8 +655,10 @@ def format_operator(operator: Operator) -> str:
def apply_alphanumeric_filter(query: dict, filter: AlphanumericFilter, collection: str) -> dict:
#LOG.debug(filter.value)
scope = filter.scope
if scope is None:
if scope is None and collection != 'g_variants':
scope = collection[0:-1]
elif scope is None:
scope = 'genomicVariation'
formatted_value = format_value(filter.value)
formatted_operator = format_operator(filter.operator)
#LOG.debug(collection)
Expand Down Expand Up @@ -890,8 +894,10 @@ def apply_custom_filter(query: dict, filter: CustomFilter, collection:str) -> di
#LOG.debug(query)

scope = filter.scope
if scope is None:
if scope is None and collection != 'g_variants':
scope = collection[0:-1]
elif scope is None:
scope = 'genomicVariation'
value_splitted = filter.id.split(':')
if value_splitted[0] in conf.alphanumeric_terms:
query_term = value_splitted[0]
Expand Down
7 changes: 5 additions & 2 deletions beacon/db/g_variants.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,14 @@ def get_variants(entry_id: Optional[str], qparams: RequestParams, dataset: str):
query_parameters, parameters_as_filters = apply_request_parameters({}, qparams)
LOG.debug(query_parameters)
LOG.debug(parameters_as_filters)
if parameters_as_filters == True:
if parameters_as_filters == True and query_parameters != {'$and': []}:
query, parameters_as_filters = apply_request_parameters({}, qparams)
query_parameters={}
else:
elif query_parameters != {'$and': []}:
query=query_parameters
elif query_parameters == {'$and': []}:
query_parameters = {}
query={}
query = apply_filters(query, qparams.query.filters, collection,query_parameters)
LOG.debug(query)
include = qparams.query.include_resultset_responses
Expand Down

0 comments on commit 369a0f5

Please sign in to comment.