Skip to content

Commit

Permalink
Merge pull request #15 from EGA-archive/testMode
Browse files Browse the repository at this point in the history
Adding Test mode and fixing case insensitive searches for filtering terms
  • Loading branch information
costero-e authored Nov 22, 2024
2 parents 1ce682e + a5225bd commit 1c0b896
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
5 changes: 4 additions & 1 deletion beacon/connections/mongo/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,7 @@ def apply_ontology_filter(self, query: dict, filter: OntologyFilter, collection:
dict_regex={}
try:
dict_regex['$regex']=label
dict_regex['$options']='i'
except Exception:
dict_regex['$regex']=''
dict_id={}
Expand Down Expand Up @@ -668,6 +669,7 @@ def apply_ontology_filter(self, query: dict, filter: OntologyFilter, collection:
dict_regex={}
try:
dict_regex['$regex']=label
dict_regex['$options']='i'
except Exception:# pragma: no cover
dict_regex['$regex']=''
dict_id={}
Expand Down Expand Up @@ -696,7 +698,6 @@ def apply_ontology_filter(self, query: dict, filter: OntologyFilter, collection:
query_id[query_term]=simil
new_query['$or'].append(query_id)
query = new_query

query=cross_query(self, query, scope, collection, request_parameters, dataset)


Expand All @@ -723,6 +724,7 @@ def apply_ontology_filter(self, query: dict, filter: OntologyFilter, collection:
query_filtering['$and'].append(dict_scope)
dict_regex={}
dict_regex['$regex']=label
dict_regex['$options']='i'
dict_id={}
dict_id['id']=dict_regex
query_filtering['$and'].append(dict_id)
Expand Down Expand Up @@ -1000,6 +1002,7 @@ def apply_alphanumeric_filter(self, query: dict, filter: AlphanumericFilter, col
dict_id={}
dict_regex={}
dict_regex['$regex']=filter.id
dict_regex['$options']='i'
dict_type['type']='custom'
dict_id['id']=dict_regex
query_filtering['$and'].append(dict_type)
Expand Down
11 changes: 11 additions & 0 deletions beacon/request/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,17 @@ def from_request(self, request: Request) -> Self:
self.query.request_parameters[k] = html.escape(v)
elif k == 'filters':
self.query.request_parameters[k] = html.escape(v)
elif k == 'testMode':
v = html.escape(v)
if v.lower() == 'true':
v = True
elif v.lower() == 'false':
v = False
else:
err = 'testMode parameter can only be either true or false value'
errcode=400
raise_exception(err, errcode)
self.query.test_mode = v
elif k in ["start", "end", "assemblyId", "referenceName", "referenceBases", "alternateBases", "variantType","variantMinLength","variantMaxLength","geneId","genomicAlleleShortForm","aminoacidChange","clinicalRelevance", "mateName"]:
try:
if ',' in v:# pragma: no cover
Expand Down
3 changes: 3 additions & 0 deletions beacon/response/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ async def builder(self, request: Request, datasets, qparams, entry_type, entry_i
complete_module='beacon.connections.'+source+'.executor'
import importlib
module = importlib.import_module(complete_module, package=None)
testMode = qparams.query.test_mode
if testMode == True:
datasets = ['test']
datasets_docs, datasets_count, count, entity_schema, include, datasets = await module.execute_function(self, entry_type, datasets, qparams, entry_id)
if include != 'NONE' and granularity == Granularity.RECORD and default_beacon_granularity == 'record':
response = build_beacon_record_response_by_dataset(self, datasets, datasets_docs, datasets_count, count, qparams, entity_schema)
Expand Down

0 comments on commit 1c0b896

Please sign in to comment.