graceguo-supercat commented on a change in pull request #10963:
URL:
https://github.com/apache/incubator-superset/pull/10963#discussion_r495292236
##########
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(
+ dashboard: Dashboard,
+) -> DefaultDict[Any, List[Any]]:
+ datasources = defaultdict(list)
+ for slc in dashboard.slices:
+ datasource = slc.datasource
+ if datasource:
+ datasources[datasource].append(slc)
+ return datasources
+
+
+def get_dashboard_latest_changed_on(_self: Any, dashboard_id_or_slug: str) ->
datetime:
Review comment:
Please see other functions that used by decorator:
```This function takes `self` since it must have the same signature as the
the decorated method.```
----------------------------------------------------------------
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]