feat: incorporated feedback comments

This commit is contained in:
Muhammad Zubair
2023-06-22 16:53:25 +05:00
committed by Phillip Shiu
parent a9afb4fb5b
commit 3133628007
2 changed files with 12 additions and 12 deletions

View File

@@ -72,7 +72,7 @@ class Command(BaseCommand):
expired_at__isnull=True, created__lte=exceptional_expiration_period, course_uuid__in=MIT_SUPPLY_CHAIN_COURSES)
entitlements = normal_entitlements | exceptional_entitlements
logger.info('Total entitlements that have reached expiration period are %d ', entitlements)
logger.info('Total entitlements that have reached expiration period are %d ', entitlements.count())
entitlements_to_expire = max(1, options.get('count'))
batch_size = max(1, options.get('batch_size'))
@@ -89,7 +89,7 @@ class Command(BaseCommand):
for batch_num in range(num_batches):
start = batch_num * batch_size
end = min(start + batch_size, entitlements_to_expire)
end = min(start + batch_size, entitlements_to_expire, entitlements.count())
expire_and_create_entitlements.delay(entitlements[start:end], support_user)
logger.info('Done. Successfully enqueued %d tasks.', num_batches)

View File

@@ -96,15 +96,15 @@ def expire_and_create_entitlements(self, entitlements, support_user):
}
CourseEntitlementSupportDetail.objects.create(**support_detail)
# Creating new entitlement with old entitlement's data
entitlement.pk = None
entitlement.id = None
entitlement._state.adding = True
entitlement.expired_at = None
entitlement.modified = None
entitlement.refund_locked = True
entitlement.save()
# Creating new entitlement and support details
new_entitlement = {
'course_uuid': entitlement.course_uuid,
'user': entitlement.user,
'mode': entitlement.mode,
'refund_locked': True,
}
CourseEntitlement.objects.create(**new_entitlement)
support_detail = {
'action': 'CREATE',
'comments': 'REV-3574',
@@ -112,7 +112,7 @@ def expire_and_create_entitlements(self, entitlements, support_user):
'support_user': support_user,
}
CourseEntitlementSupportDetail.objects.create(**support_detail)
LOGGER.info('created new entitlement with id %d in a correspondence of above expired entitlement', entitlement.id)
LOGGER.info('created new entitlement with id %d in a correspondence of above expired entitlement', new_entitlement.id)
except Exception as exc:
LOGGER.exception('Failed to expire entitlements that reached their expiration period',)