From 33bc48b8de633eb95d551a0bcd5b1a8fff6c1034 Mon Sep 17 00:00:00 2001 From: Muhammad Zubair Date: Tue, 20 Jun 2023 20:48:39 +0500 Subject: [PATCH] feat: resolved linting issues --- .../commands/expire_and_create_entitlements.py | 2 +- common/djangoapps/entitlements/tasks.py | 15 ++++++--------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/common/djangoapps/entitlements/management/commands/expire_and_create_entitlements.py b/common/djangoapps/entitlements/management/commands/expire_and_create_entitlements.py index 89eec99ab7..8f6ae14133 100644 --- a/common/djangoapps/entitlements/management/commands/expire_and_create_entitlements.py +++ b/common/djangoapps/entitlements/management/commands/expire_and_create_entitlements.py @@ -64,7 +64,7 @@ class Command(BaseCommand): while total > 0: total = total - batch_size - no_of_entitlements = min(total, batch_size) + no_of_entitlements = min(total, batch_size) expire_and_create_entitlements.delay(no_of_entitlements) logger.info('Done. Successfully enqueued %d tasks.', num_batches) diff --git a/common/djangoapps/entitlements/tasks.py b/common/djangoapps/entitlements/tasks.py index faab8a210d..ce908abcda 100644 --- a/common/djangoapps/entitlements/tasks.py +++ b/common/djangoapps/entitlements/tasks.py @@ -10,7 +10,6 @@ from django.conf import settings # lint-amnesty, pylint: disable=unused-import from edx_django_utils.monitoring import set_code_owner_attribute from common.djangoapps.entitlements.models import CourseEntitlement -from common.djangoapps.entitlements.rest_api.v1.views import EntitlementViewSet LOGGER = get_task_logger(__name__) @@ -72,7 +71,7 @@ def expire_old_entitlements(self, start, end, logid='...'): raise self.retry(exc=exc, countdown=countdown, max_retries=MAX_RETRIES) LOGGER.info('Successfully completed the task expire_old_entitlements after examining %d entries [%s]', entitlements.count(), logid) # lint-amnesty, pylint: disable=line-too-long - + @shared_task(bind=True, ignore_result=True) @set_code_owner_attribute @@ -93,16 +92,14 @@ def expire_and_create_entitlements(self, no_of_entitlements): current_date = date.today() expiration_period = current_date - relativedelta(years=1) exceptional_expiration_period = current_date - relativedelta(years=1, months=6) - normal_entitlements = CourseEntitlement.objects.filter(expired_at__isnull=True, - created__lte=expiration_period).exclude(course_uuid__in=MIT_SUPPLY_CHAIN_COURSES) - exceptional_entitlements = CourseEntitlement.objects.filter(expired_at__isnull=True, - created__lte=exceptional_expiration_period, course_uuid__in=MIT_SUPPLY_CHAIN_COURSES) - + normal_entitlements = CourseEntitlement.objects.filter( + expired_at__isnull=True, created__lte=expiration_period).exclude(course_uuid__in=MIT_SUPPLY_CHAIN_COURSES) + exceptional_entitlements = CourseEntitlement.objects.filter( + expired_at__isnull=True, created__lte=exceptional_expiration_period, course_uuid__in=MIT_SUPPLY_CHAIN_COURSES) + entitlements = normal_entitlements | exceptional_entitlements - countdown = 2 ** self.request.retries - try: for entitlement in entitlements[:no_of_entitlements]: