From 4b1ad4546a1c468202d683e35f11e9635efbe3d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=86=D0=B2=D0=B0=D0=BD=20=D0=9D=D1=94=D0=B4=D1=94=D0=BB?= =?UTF-8?q?=D1=8C=D0=BD=D1=96=D1=86=D0=B5=D0=B2?= Date: Tue, 16 Apr 2024 15:50:23 +0300 Subject: [PATCH 1/3] fix: [AXIMST-806] change course version to edited timestamp --- lms/djangoapps/course_home_api/outline/views.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lms/djangoapps/course_home_api/outline/views.py b/lms/djangoapps/course_home_api/outline/views.py index 1d02261dbc0c..ebe0f9c2e0b5 100644 --- a/lms/djangoapps/course_home_api/outline/views.py +++ b/lms/djangoapps/course_home_api/outline/views.py @@ -416,7 +416,7 @@ class CourseNavigationBlocksView(RetrieveAPIView): serializer_class = CourseBlockSerializer COURSE_BLOCKS_CACHE_KEY_TEMPLATE = ( - 'course_sidebar_blocks_{course_key_string}_{course_version}_{user_id}_{user_cohort_id}' + 'course_sidebar_blocks_{course_key_string}_{course_edited_timestamp}_{user_id}_{user_cohort_id}' '_{enrollment_mode}_{allow_public}_{allow_public_outline}_{is_masquerading}' ) COURSE_BLOCKS_CACHE_TIMEOUT = 60 * 60 # 1 hour @@ -451,7 +451,7 @@ def get(self, request, *args, **kwargs): cache_key = self.COURSE_BLOCKS_CACHE_KEY_TEMPLATE.format( course_key_string=course_key_string, - course_version=str(course.course_version), + course_edited_timestamp=str(course.subtree_edited_on.timestamp()), user_id=request.user.id, enrollment_mode=getattr(enrollment, 'mode', ''), user_cohort_id=getattr(user_cohort, 'id', ''), From d592955054e1e7f904fcca17f975d8ed3149030f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=86=D0=B2=D0=B0=D0=BD=20=D0=9D=D1=94=D0=B4=D1=94=D0=BB?= =?UTF-8?q?=D1=8C=D0=BD=D1=96=D1=86=D0=B5=D0=B2?= Date: Tue, 16 Apr 2024 17:46:02 +0300 Subject: [PATCH 2/3] fix: [AXIMST-806] disable course blocks getting request caching --- lms/djangoapps/course_home_api/outline/views.py | 10 +++++++--- lms/djangoapps/courseware/toggles.py | 2 +- openedx/features/course_experience/utils.py | 11 +++++++++++ 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/lms/djangoapps/course_home_api/outline/views.py b/lms/djangoapps/course_home_api/outline/views.py index ebe0f9c2e0b5..f116ce1092b6 100644 --- a/lms/djangoapps/course_home_api/outline/views.py +++ b/lms/djangoapps/course_home_api/outline/views.py @@ -56,7 +56,11 @@ get_current_update_for_user ) from openedx.features.course_experience.url_helpers import get_learning_mfe_home_url -from openedx.features.course_experience.utils import get_course_outline_block_tree, get_start_block +from openedx.features.course_experience.utils import ( + get_course_outline_block_tree, + get_course_outline_block_tree_with_cache, + get_start_block +) from openedx.features.discounts.utils import generate_offer_data from xmodule.course_block import COURSE_VISIBILITY_PUBLIC, COURSE_VISIBILITY_PUBLIC_OUTLINE # lint-amnesty, pylint: disable=wrong-import-order @@ -243,7 +247,7 @@ def get(self, request, *args, **kwargs): # pylint: disable=too-many-statements show_enrolled = is_enrolled or is_staff enable_proctored_exams = False if show_enrolled: - course_blocks = get_course_outline_block_tree(request, course_key_string, request.user) + course_blocks = get_course_outline_block_tree_with_cache(request, course_key_string, request.user) date_blocks = get_course_date_blocks(course, request.user, request, num_assignments=1) dates_widget['course_date_blocks'] = [block for block in date_blocks if not isinstance(block, TodaysDate)] @@ -278,7 +282,7 @@ def get(self, request, *args, **kwargs): # pylint: disable=too-many-statements resume_course['url'] = start_block['lms_web_url'] elif allow_public_outline or allow_public or user_is_masquerading: - course_blocks = get_course_outline_block_tree(request, course_key_string, None) + course_blocks = get_course_outline_block_tree_with_cache(request, course_key_string, None) if allow_public or user_is_masquerading: handouts_html = get_course_info_section(request, request.user, course, 'handouts') diff --git a/lms/djangoapps/courseware/toggles.py b/lms/djangoapps/courseware/toggles.py index 4aadfd3e93ed..65e7d4718d91 100644 --- a/lms/djangoapps/courseware/toggles.py +++ b/lms/djangoapps/courseware/toggles.py @@ -68,7 +68,7 @@ f'{WAFFLE_FLAG_NAMESPACE}.mfe_courseware_search', __name__ ) -# .. toggle_name: courseware.navigation_sidebar_blocks_caching +# .. toggle_name: courseware.disable_navigation_sidebar_blocks_caching # .. toggle_implementation: WaffleFlag # .. toggle_default: False # .. toggle_description: Disable caching of navigation sidebar blocks on Learning MFE. diff --git a/openedx/features/course_experience/utils.py b/openedx/features/course_experience/utils.py index 4675d0a974e0..b66d8a15764b 100644 --- a/openedx/features/course_experience/utils.py +++ b/openedx/features/course_experience/utils.py @@ -15,6 +15,17 @@ @request_cached() +def get_course_outline_block_tree_with_cache(request, course_id, user=None, allow_start_dates_in_future=False): + """ + Returns the root block of the course outline, with children as blocks. + + allow_start_dates_in_future (bool): When True, will allow blocks to be + returned that can bypass the StartDateTransformer's filter to show + blocks with start dates in the future. + """ + return get_course_outline_block_tree(request, course_id, user, allow_start_dates_in_future) + + def get_course_outline_block_tree(request, course_id, user=None, allow_start_dates_in_future=False): # lint-amnesty, pylint: disable=too-many-statements """ Returns the root block of the course outline, with children as blocks. From 693b86e560b828699a3bfbd649e63886db32c7af Mon Sep 17 00:00:00 2001 From: Ivan Niedielnitsev <81557788+NiedielnitsevIvan@users.noreply.github.com> Date: Wed, 17 Apr 2024 16:26:03 +0300 Subject: [PATCH 3/3] style: fix indentations Co-authored-by: monteri <36768631+monteri@users.noreply.github.com> --- openedx/features/course_experience/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openedx/features/course_experience/utils.py b/openedx/features/course_experience/utils.py index b66d8a15764b..44170cff4998 100644 --- a/openedx/features/course_experience/utils.py +++ b/openedx/features/course_experience/utils.py @@ -20,8 +20,8 @@ def get_course_outline_block_tree_with_cache(request, course_id, user=None, allo Returns the root block of the course outline, with children as blocks. allow_start_dates_in_future (bool): When True, will allow blocks to be - returned that can bypass the StartDateTransformer's filter to show - blocks with start dates in the future. + returned that can bypass the StartDateTransformer's filter to show + blocks with start dates in the future. """ return get_course_outline_block_tree(request, course_id, user, allow_start_dates_in_future)