graceguo-supercat commented on a change in pull request #10963:
URL: 
https://github.com/apache/incubator-superset/pull/10963#discussion_r495289551



##########
File path: superset/views/utils.py
##########
@@ -298,6 +306,46 @@ def get_time_range_endpoints(
 CONTAINER_TYPES = ["COLUMN", "GRID", "TABS", "TAB", "ROW"]
 
 
+def get_dashboard(dashboard_id_or_slug: str,) -> Dashboard:
+    session = db.session()
+    qry = session.query(Dashboard)
+    if dashboard_id_or_slug.isdigit():
+        qry = qry.filter_by(id=int(dashboard_id_or_slug))
+    else:
+        qry = qry.filter_by(slug=dashboard_id_or_slug)
+    dashboard = qry.one_or_none()
+
+    if not dashboard:
+        abort(404)
+
+    return dashboard
+
+
+def get_datasources_from_dashboard(

Review comment:
       this is a little confusing: Dashboard class has a get `datasources` 
function. So i use it in `check_dashboard_perms` function. But this function is 
to group slices by datasources, and the result will be used by another feature: 
   
https://github.com/apache/incubator-superset/blob/ba009b7c09d49f2932fd10269882c901bc020c1d/superset/views/core.py#L1626
   Instead of datasource.data,  datasource.data_for_slices(slices) can reduce 
the initial dashboard data load size.
   
   So right now i removed this helper function from utils, and build dict in 
the dashboard function. But i rename datasource to `slices_by_datasources` for 
clarification.




----------------------------------------------------------------
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.

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