etr2460 commented on a change in pull request #14357:
URL: https://github.com/apache/superset/pull/14357#discussion_r621817401



##########
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:
       Yeah, i noticed that too. The db call should be very fast since it's 
indexed, so i didn't think it was too big of a deal. Maybe it's worth caching 
for the request lifespan though. Honestly, I wonder if sqlalchemy could do 
something like that for us




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