Skip to content

Commit

Permalink
temp: add temporary logging for entitlement revocation (#32746)
Browse files Browse the repository at this point in the history
* temp: add temporary logging for entitlement revocation
  • Loading branch information
aht007 authored Jul 14, 2023
1 parent 5d72ba3 commit 024096a
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 4 deletions.
13 changes: 13 additions & 0 deletions common/djangoapps/entitlements/rest_api/v1/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,8 +556,16 @@ def _process_revoke_and_downgrade_to_audit(self, course_entitlements, user_id, r
if course_entitlement.enrollment_course_run is not None:
entitled_course_ids.append(str(course_entitlement.enrollment_course_run.course_id))

log.info('B2C_SUBSCRIPTIONS: Getting course completion status for user %s and entitled_course_ids %s',
user_id,
entitled_course_ids)
awarded_cert_course_ids, is_exception = get_courses_completion_status(user_id, entitled_course_ids)

log.info('B2C_SUBSCRIPTIONS: Got course completion response %s for user %s and entitled_course_ids %s',
awarded_cert_course_ids,
user_id,
entitled_course_ids)

if is_exception:
# Trigger the retry task asynchronously
log.exception('B2C_SUBSCRIPTIONS: Exception occurred while getting course completion status for user %s '
Expand All @@ -568,6 +576,11 @@ def _process_revoke_and_downgrade_to_audit(self, course_entitlements, user_id, r
entitled_course_ids,
user_id))
return
log.info('B2C_SUBSCRIPTIONS: Starting revoke_entitlements_and_downgrade_courses_to_audit for user %s and '
'awarded_cert_course_ids %s and revocable_entitlement_uuids %s',
user_id,
awarded_cert_course_ids,
revocable_entitlement_uuids)
revoke_entitlements_and_downgrade_courses_to_audit(course_entitlements, user_id, awarded_cert_course_ids,
revocable_entitlement_uuids)

Expand Down
5 changes: 5 additions & 0 deletions common/djangoapps/entitlements/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,11 @@ def retry_revoke_subscriptions_verified_access(self, revocable_entitlement_uuids
user_id,
revocable_entitlement_uuids
)
log.info('B2C_SUBSCRIPTIONS: Starting revoke_entitlements_and_downgrade_courses_to_audit for user %s and '
'awarded_cert_course_ids %s and revocable_entitlement_uuids %s from retry task',
user_id,
awarded_cert_course_ids,
revocable_entitlement_uuids)
revoke_entitlements_and_downgrade_courses_to_audit(course_entitlements, user_id, awarded_cert_course_ids,
revocable_entitlement_uuids)
else:
Expand Down
10 changes: 6 additions & 4 deletions common/djangoapps/entitlements/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,10 @@ def revoke_entitlements_and_downgrade_courses_to_audit(course_entitlements, user
"""

log.info('B2C_SUBSCRIPTIONS: Starting revoke_entitlements_and_downgrade_courses_to_audit for '
'user: %s and course_entitlements_uuids: %s',
'user: %s, course_entitlements_uuids: %s, awarded_cert_course_ids: %s',
user_id,
revocable_entitlement_uuids)
revocable_entitlement_uuids,
awarded_cert_course_ids)
for course_entitlement in course_entitlements:
if course_entitlement.enrollment_course_run is None:
if course_entitlement.expired_at is None:
Expand All @@ -90,6 +91,7 @@ def revoke_entitlements_and_downgrade_courses_to_audit(course_entitlements, user
user_id,
course_id)
log.info('B2C_SUBSCRIPTIONS: Completed revoke_entitlements_and_downgrade_courses_to_audit for '
'user: %s and course_entitlements_uuids %s',
'user: %s, course_entitlements_uuids: %s, awarded_cert_course_ids: %s',
user_id,
revocable_entitlement_uuids)
revocable_entitlement_uuids,
awarded_cert_course_ids)
8 changes: 8 additions & 0 deletions openedx/core/djangoapps/credentials/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,18 @@ def get_courses_completion_status(lms_user_id, course_run_ids):
return [], True
# Yes, This is course_credentials_data. The key is named status but
# it contains all the courses data from credentials.
log.info("Course completion status response for lms_user_id [%s] for course_run_ids [%s] is [%s]",
lms_user_id,
course_run_ids,
course_completion_response)
course_credentials_data = course_completion_response.get('status', [])
if course_credentials_data is not None:
filtered_records = [course_data['course_run']['key'] for course_data in course_credentials_data if
course_data['course_run']['key'] in course_run_ids and
course_data['status'] == settings.CREDENTIALS_COURSE_COMPLETION_STATE]
log.info("Filtered course completion status response for lms_user_id [%s] for course_run_ids [%s] is [%s]",
lms_user_id,
course_run_ids,
filtered_records)
return filtered_records, False
return [], False

0 comments on commit 024096a

Please sign in to comment.