ktmud commented on a change in pull request #14357:
URL: https://github.com/apache/superset/pull/14357#discussion_r621814341
##########
File path: superset/dashboards/api.py
##########
@@ -210,6 +211,23 @@ def __init__(self) -> None:
self.include_route_methods = self.include_route_methods |
{"thumbnail"}
super().__init__()
+ def __repr__(self) -> str:
+ """Deterministic string representation of the API instance for
etag_cache."""
+ return "Superset.dashboards.api.DashboardRestApi@v{}{}".format(
+ self.appbuilder.app.config["VERSION_STRING"],
+ self.appbuilder.app.config["VERSION_SHA"],
+ )
+
+ @etag_cache(
+ get_last_modified=lambda _self, id_or_slug:
DashboardDAO.get_dashboard_changed_on( # pylint: disable=line-too-long
+ id_or_slug
+ ),
+ max_age=0,
+ raise_for_access=lambda _self, id_or_slug:
DashboardDAO.get_by_id_or_slug(
+ id_or_slug
+ ),
Review comment:
So it seems `DashboardDAO.get_by_id_or_slug` will be called at least 3
times on first visit (no etag). I'm starting to wonder whether it's worth it to
move everything out of the view handler. Maybe some direct function calls would
be both more performant and easier to understand.
--
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]