bkyryliuk commented on a change in pull request #10963:
URL:
https://github.com/apache/incubator-superset/pull/10963#discussion_r496159461
##########
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:
+ """
+ Get latest changed datetime for a dashboard. The change could be dashboard
Review comment:
can we get more specific with _self type ?
##########
File path: superset/utils/decorators.py
##########
@@ -89,13 +94,26 @@ def wrapper(*args: Any, **kwargs: Any) -> ETagResponseMixin:
raise
logger.exception("Exception possibly due to cache
backend.")
+ # if cache is stale?
+ if get_latest_changed_on:
+ content_changed_time = get_latest_changed_on(*args, **kwargs)
+ if (
+ response
+ and response.last_modified
+ and response.last_modified.timestamp()
+ < content_changed_time.timestamp()
+ ):
+ response = None
+ else:
+ content_changed_time = datetime.utcnow()
Review comment:
add a comment here why content_changed_time is set to now()
----------------------------------------------------------------
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]