|
37 | 37 | import pandas as pd |
38 | 38 |
|
39 | 39 | from sqlalchemy import distinct, exists |
| 40 | +from sqlalchemy.orm import lazyload, joinedload, contains_eager, eagerload, defer, deferred, subqueryload |
40 | 41 |
|
41 | 42 | __author__ = 'sreeder' |
42 | 43 |
|
@@ -78,7 +79,6 @@ class SamplingFeatureDataSet(): |
78 | 79 | def __init__(self, samplingfeature, datasetresults, relatedfeatures): |
79 | 80 | sf = samplingfeature |
80 | 81 |
|
81 | | - self.SamplingFeature = sf |
82 | 82 | self.SamplingFeatureID = sf.SamplingFeatureID |
83 | 83 | self.SamplingFeatureUUID = sf.SamplingFeatureUUID |
84 | 84 | self.SamplingFeatureTypeCV = sf.SamplingFeatureTypeCV |
@@ -955,10 +955,24 @@ def getSamplingFeatureDatasets(self, ids=None, codes=None, uuids=None, dstype=No |
955 | 955 | sfds=[] |
956 | 956 | for sf in sf_list: |
957 | 957 |
|
958 | | - q = self._session.query(DataSetsResults)\ |
959 | | - .join(Results)\ |
960 | | - .join(FeatureActions)\ |
961 | | - .filter(FeatureActions.SamplingFeatureID == sf.SamplingFeatureID) |
| 958 | + # q = self._session.query(DataSetsResults)\ |
| 959 | + # .options(subqueryload(DataSetsResults.ResultObj)\ |
| 960 | + # .subqueryload(Results.FeatureActionObj)\ |
| 961 | + # .load_only(FeatureActions.SamplingFeatureID))\ |
| 962 | + # .filter(FeatureActions.SamplingFeatureID == sf.SamplingFeatureID) |
| 963 | + |
| 964 | + q = self._session.query(DataSetsResults) \ |
| 965 | + .join(DataSetsResults.ResultObj)\ |
| 966 | + .join(Results.FeatureActionObj)\ |
| 967 | + .filter(FeatureActions.SamplingFeatureID == sf.SamplingFeatureID)\ |
| 968 | + .options(contains_eager(DataSetsResults.ResultObj).contains_eager(Results.FeatureActionObj)\ |
| 969 | + .load_only(FeatureActions.SamplingFeatureID)) |
| 970 | + |
| 971 | + # q = self._session.query(DataSetsResults)\ |
| 972 | + # .join(Results)\ |
| 973 | + # .join(FeatureActions)\ |
| 974 | + # .filter(FeatureActions.SamplingFeatureID == sf.SamplingFeatureID) |
| 975 | + |
962 | 976 |
|
963 | 977 | if dstype: |
964 | 978 | q = q.filter_by(DatasetTypeCV=dstype) |
|
0 commit comments