john-bodley commented on a change in pull request #15648:
URL: https://github.com/apache/superset/pull/15648#discussion_r668774483



##########
File path: superset/models/dashboard.py
##########
@@ -171,8 +172,17 @@ def url(self) -> str:
 
     @property
     def datasources(self) -> Set[BaseDatasource]:
-        # pylint: disable=using-constant-test
-        return {slc.datasource for slc in self.slices if slc.datasource}
+        # Verbose but efficient database enumeration of dashboard datasources.
+        datasources = {(slc.cls_model, slc.datasource_id) for slc in 
self.slices}
+        result: Set[BaseDatasource] = set()
+
+        for cls_model, datasource_id in datasources:
+            datasource = 
db.session.query(cls_model).filter_by(id=datasource_id).first()
+
+            if datasource:
+                result.add(datasource)
+
+        return result

Review comment:
       Agreed @ktmud. I initially didn’t refactor this method and thus did a 
somewhat copy-and-paste from the other refactor. 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to