Skip to content

Commit c646fb2

Browse files
author
sreeder
committed
add sampling feature and variables filter in the getresults function
1 parent 07875b2 commit c646fb2

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

odm2api/ODM2/services/readService.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -514,14 +514,17 @@ def getAffiliations(self, ids=None, personfirst=None, personlast=None, orgcode=N
514514
Results
515515
"""
516516

517-
def getResults(self, ids=None, type= None, uuids= None, actionid=None, simulationid = None):
517+
def getResults(self, ids=None, type= None, uuids= None, actionid=None, simulationid = None, sfid= None, variableid = None):
518518

519519
# TODO what if user sends in both type and actionid vs just actionid
520520
"""
521521
getResults()
522522
* Pass nothing - returns a list of all Results objects
523523
* Pass a list of ResultID - returns a single Results object
524524
* Pass an ActionID - returns a single Results object
525+
* Pass a Sampling Feature ID- returns a list of objects with that Sampling Feature ID
526+
* Pass a Variable ID - returns a list of results with that Variable ID
527+
* Pass a Simulation ID - return a list of results that were generated by that simulation
525528
"""
526529

527530
query = self._session.query(Results)
@@ -531,9 +534,11 @@ def getResults(self, ids=None, type= None, uuids= None, actionid=None, simulati
531534
if simulationid: query = query.join(FeatureActions)\
532535
.join(Actions)\
533536
.join(Simulations)\
534-
.filter_by(SimulationID = simulationid)
537+
.filter_by(SimulationID=simulationid)
535538
if ids: query = query.filter(Results.ResultID.in_(ids))
536539
if uuids: query =query.filter(Results.ResultUUID.in_(uuids))
540+
if sfid: query = query.join(FeatureActions).filter_by(SamplingFeatureID=sfid)
541+
if variableid: query = query.filter_by(VariableID=variableid)
537542

538543
try:
539544
return query.all()

0 commit comments

Comments
 (0)