Skip to content

Commit

Permalink
fix: add cache wrapper for can_view_courses filter
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian2012 committed Aug 25, 2023
1 parent c5868fb commit a3cda98
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import jwt
from authlib.common.urls import add_params_to_qs, add_params_to_uri
from flask import current_app, session, request
from flask import current_app, session
from superset.security import SupersetSecurityManager
from superset.utils.memoized import memoized

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,15 @@
# Add this custom template processor which returns the list of courses the current user can access
from openedx_jinja_filters import *

def can_view_courses_wrapper(*args, **kwargs):
from superset.utils.cache import memoized_func
from superset.extensions import cache_manager

return memoized_func(key="{username}", cache=cache_manager.cache)(can_view_courses)(*args, **kwargs)


JINJA_CONTEXT_ADDONS = {
'can_view_courses': can_view_courses,
'can_view_courses': can_view_courses_wrapper,
{% for filter in SUPERSET_EXTRA_JINJA_FILTERS %}'{{ filter }}': {{filter}},{% endfor %}
}

Expand Down

0 comments on commit a3cda98

Please sign in to comment.