Skip to content

Commit

Permalink
Merge pull request #299 from openedx/cag/add-cache-to-filters
Browse files Browse the repository at this point in the history
fix: add cache wrapper for can_view_courses filter
  • Loading branch information
Ian2012 authored Aug 25, 2023
2 parents c5868fb + a3cda98 commit ff530c8
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 ff530c8

Please sign in to comment.