villebro commented on code in PR #21439:
URL: https://github.com/apache/superset/pull/21439#discussion_r968948319
##########
superset/views/base.py:
##########
@@ -340,22 +342,27 @@ def menu_data() -> Dict[str, Any]:
"build_number": build_number,
"languages": languages,
"show_language_picker": len(languages.keys()) > 1,
- "user_is_anonymous": g.user.is_anonymous,
+ "user_is_anonymous": user.is_anonymous,
"user_info_url": None
if appbuilder.app.config["MENU_HIDE_USER_INFO"]
else appbuilder.get_url_for_userinfo,
"user_logout_url": appbuilder.get_url_for_logout,
"user_login_url": appbuilder.get_url_for_login,
"user_profile_url": None
- if g.user.is_anonymous or
appbuilder.app.config["MENU_HIDE_USER_INFO"]
- else f"/superset/profile/{g.user.username}",
+ if user.is_anonymous or
appbuilder.app.config["MENU_HIDE_USER_INFO"]
+ else f"/superset/profile/{user.username}",
"locale": session.get("locale", "en"),
},
}
-def common_bootstrap_payload() -> Dict[str, Any]:
- """Common data always sent to the client"""
+@cache_manager.cache.memoize(timeout=60)
+def common_bootstrap_payload(user: User) -> Dict[str, Any]:
Review Comment:
I checked the docs, and while they appear to recommend not using mutable
objects as the key, it should work in this case as `__repr__()` will always
return the same value for a single user.
Memoization docs: https://flask-caching.readthedocs.io/en/latest/#memoization
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]