etr2460 commented on a change in pull request #9284: Reduce dashboard bootstrap
payload
URL:
https://github.com/apache/incubator-superset/pull/9284#discussion_r391333057
##########
File path: superset/views/core.py
##########
@@ -1788,25 +1788,40 @@ def dashboard(self, dashboard_id):
dash = qry.one_or_none()
if not dash:
abort(404)
- datasources = set()
+ datasources = {}
for slc in dash.slices:
datasource = slc.datasource
if datasource:
- datasources.add(datasource)
+ if datasources.get(datasource.uid):
+ datasources[datasource.uid]["slices"].append(slc)
+ else:
+ datasources[datasource.uid] = {
+ "datasource": datasource,
+ "slices": [slc],
+ }
if config["ENABLE_ACCESS_REQUEST"]:
- for datasource in datasources:
- if datasource and not
security_manager.datasource_access(datasource):
+ for value in datasources.values():
+ if datasource and not security_manager.datasource_access(
+ value["datasource"]
+ ):
flash(
__(
-
security_manager.get_datasource_access_error_msg(datasource)
+ security_manager.get_datasource_access_error_msg(
+ value["datasource"]
+ )
),
"danger",
)
return redirect(
"superset/request_access/?" f"dashboard_id={dash.id}&"
)
+ # Filter out unneeded fields from the datasource payload
+ for key, value in datasources.items():
+ datasource_data =
value["datasource"].data_for_slices(value["slices"])
+ datasources[key] = datasource_data
Review comment:
ah, yup. that's definitely better. i had a refactor but didn't clean this up
----------------------------------------------------------------
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]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]