From d833a62ec86764292156df0e5099d6147a1db6cf Mon Sep 17 00:00:00 2001 From: Maria Grimaldi Date: Mon, 2 Dec 2024 21:52:25 +0100 Subject: [PATCH] refactor: don't evaluate queryset before filtering/ordering --- cms/djangoapps/contentstore/views/course.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cms/djangoapps/contentstore/views/course.py b/cms/djangoapps/contentstore/views/course.py index 08fc3c2739ca..b0899b60a953 100644 --- a/cms/djangoapps/contentstore/views/course.py +++ b/cms/djangoapps/contentstore/views/course.py @@ -575,9 +575,10 @@ def filter_ccx(course_access): if course_keys: courses_list = CourseOverview.get_all_courses(filter_={'id__in': course_keys}) - - if not courses_list: - return [], [] + else: + # If no course keys are found for the current user, then return without filtering + # or ordering the courses list. + return courses_list, [] search_query, order, active_only, archived_only = get_query_params_if_present(request) courses_list = get_filtered_and_ordered_courses(