From 8bbea7f89af372416693f86e061feda8cc227679 Mon Sep 17 00:00:00 2001 From: Dillon Dumesnil Date: Mon, 1 Mar 2021 09:29:20 -0500 Subject: [PATCH] AA-682: Update the pseudo session fallback session There was a bug where the earliest course returned for a pseudo session (when there were no available sessions) might not exist in modulestore and would cause a 500 error. The data problem is another issue that will need to be fixed, but by switching to the most recent session in this scenario, we believe we will reduce the likelihood of this error occurring. We also believe the most recent session is a better return value than the first ever session. --- openedx/core/djangoapps/catalog/utils.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/openedx/core/djangoapps/catalog/utils.py b/openedx/core/djangoapps/catalog/utils.py index 6a2a746a49..0a37627be2 100644 --- a/openedx/core/djangoapps/catalog/utils.py +++ b/openedx/core/djangoapps/catalog/utils.py @@ -526,7 +526,8 @@ def get_pseudo_session_for_entitlement(entitlement): This function is used to pass pseudo-data to the front end, returning a single session, regardless of whether that session is currently available. - First tries to return the first available session, followed by the first session regardless of availability. + First tries to return the first available session. If there are no available sessions, will try + to return the most recent session regardless of availability. Returns None if there are no sessions for that course. """ sessions_for_course = get_course_runs_for_course(entitlement.course_uuid) @@ -534,7 +535,7 @@ def get_pseudo_session_for_entitlement(entitlement): if available_sessions: return available_sessions[0] if sessions_for_course: - return sessions_for_course[0] + return sessions_for_course[-1] return None