Skip to content

Commit

Permalink
fix: rename update cache functions to what they are
Browse files Browse the repository at this point in the history
  • Loading branch information
ashultz0 committed Oct 20, 2023
1 parent c597303 commit c3a24c1
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions common/djangoapps/student/models/course_enrollment.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ def update_enrollment(self, mode=None, is_active=None, skip_refund=False, enterp

if activation_changed or mode_changed:
self.save()
self._update_enrollment_in_request_cache(
self._update_enrollment_state_in_request_cache(
self.user,
self.course_id,
CourseEnrollmentState(self.mode, self.is_active),
Expand Down Expand Up @@ -1337,7 +1337,7 @@ def _get_enrollment_state(cls, user, course_key):
enrollment_state = CourseEnrollmentState(record.mode, record.is_active)
except cls.DoesNotExist:
enrollment_state = CourseEnrollmentState(None, None)
cls._update_enrollment_in_request_cache(user, course_key, enrollment_state)
cls._update_enrollment_state_in_request_cache(user, course_key, enrollment_state)
return enrollment_state

@classmethod
Expand All @@ -1354,7 +1354,7 @@ def bulk_fetch_enrollment_states(cls, users, course_key):
cache = cls._get_mode_active_request_cache() # lint-amnesty, pylint: disable=redefined-outer-name
for record in records:
enrollment_state = CourseEnrollmentState(record.mode, record.is_active)
cls._update_enrollment(cache, record.user.id, course_key, enrollment_state)
cls._update_enrollment_state_in_cache(cache, record.user.id, course_key, enrollment_state)

@classmethod
def _get_mode_active_request_cache(cls):
Expand All @@ -1372,15 +1372,16 @@ def _get_enrollment_in_request_cache(cls, user, course_key):
return cls._get_mode_active_request_cache().get((user.id, course_key))

@classmethod
def _update_enrollment_in_request_cache(cls, user, course_key, enrollment_state):
def _update_enrollment_state_in_request_cache(cls, user, course_key, enrollment_state):
"""
Updates the cached value for the user's enrollment in the
request cache.
"""
cls._update_enrollment(cls._get_mode_active_request_cache(), user.id, course_key, enrollment_state)
cls._update_enrollment_state_in_cache(cls._get_mode_active_request_cache(),
user.id, course_key, enrollment_state)

@classmethod
def _update_enrollment(cls, cache, user_id, course_key, enrollment_state): # lint-amnesty, pylint: disable=redefined-outer-name
def _update_enrollment_state_in_cache(cls, cache, user_id, course_key, enrollment_state): # lint-amnesty, pylint: disable=redefined-outer-name
"""
Updates the cached value for the user's enrollment in the
given cache.
Expand Down

0 comments on commit c3a24c1

Please sign in to comment.