fix: remove extras and enhance existing subs logging (#32919)

This commit is contained in:
Mohammad Ahtasham ul Hassan
2023-08-07 18:01:50 +05:00
committed by GitHub
parent 1584dbc7a3
commit df197837cb
3 changed files with 12 additions and 26 deletions

View File

@@ -565,11 +565,6 @@ class SubscriptionsRevokeVerifiedAccessView(APIView):
entitled_course_ids)
awarded_cert_course_ids, is_exception = get_courses_completion_status(username, entitled_course_ids)
log.info('B2C_SUBSCRIPTIONS: Got course completion response %s for user [%s] and entitled_course_ids %s',
awarded_cert_course_ids,
username,
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 '
@@ -580,11 +575,6 @@ class SubscriptionsRevokeVerifiedAccessView(APIView):
entitled_course_ids,
username))
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',
username,
awarded_cert_course_ids,
revocable_entitlement_uuids)
revoke_entitlements_and_downgrade_courses_to_audit(course_entitlements, username, awarded_cert_course_ids,
revocable_entitlement_uuids)

View File

@@ -162,6 +162,11 @@ def retry_revoke_subscriptions_verified_access(self, revocable_entitlement_uuids
Task to process course access revoke and move to audit.
This is called only if call to get_courses_completion_status fails due to any exception.
"""
LOGGER.info("B2C_SUBSCRIPTIONS: Running retry_revoke_subscriptions_verified_access for user [%s],"
" entitlement_uuids %s and entitled_course_ids %s",
username,
revocable_entitlement_uuids,
entitled_course_ids)
course_entitlements = CourseEntitlement.objects.filter(uuid__in=revocable_entitlement_uuids)
course_entitlements = course_entitlements.select_related('user').select_related('enrollment_course_run')
if course_entitlements.exists():
@@ -171,22 +176,17 @@ def retry_revoke_subscriptions_verified_access(self, revocable_entitlement_uuids
countdown = 2 ** self.request.retries
self.retry(countdown=countdown, max_retries=3)
except MaxRetriesExceededError:
log.exception(
LOGGER.exception(
'B2C_SUBSCRIPTIONS: Failed to process retry_revoke_subscriptions_verified_access '
'for user [%s] and entitlement_uuids %s',
username,
revocable_entitlement_uuids
)
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 from retry task',
username,
awarded_cert_course_ids,
revocable_entitlement_uuids)
revoke_entitlements_and_downgrade_courses_to_audit(course_entitlements, username, awarded_cert_course_ids,
revocable_entitlement_uuids)
else:
log.info('B2C_SUBSCRIPTIONS: Entitlements not found for the provided entitlements uuids %s '
'for user [%s] duing the retry_revoke_subscriptions_verified_access task',
revocable_entitlement_uuids,
username)
LOGGER.info('B2C_SUBSCRIPTIONS: Entitlements not found for the provided entitlements uuids %s '
'for user [%s] duing the retry_revoke_subscriptions_verified_access task',
revocable_entitlement_uuids,
username)

View File

@@ -148,20 +148,16 @@ def get_courses_completion_status(username, course_run_ids):
exc
)
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 user [%s] for course_run_ids [%s] is [%s]",
username,
course_run_ids,
course_completion_response)
# Yes, This is course_credentials_data. The key is named status but
# it contains all the courses data from credentials.
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 user [%s] for course_run_ids [%s] is [%s]",
username,
course_run_ids,
filtered_records)
return filtered_records, False
return [], False