diff --git a/common/djangoapps/enrollment/__init__.py b/common/djangoapps/enrollment/__init__.py index 2f9cdfbee479c2a67a0bbf1c5db0f7c4ce1e67d3..963bb1d78f9adaf306ae7c7d002b601362d4b6f0 100644 --- a/common/djangoapps/enrollment/__init__.py +++ b/common/djangoapps/enrollment/__init__.py @@ -1,10 +1,3 @@ """ Enrollment API helpers and settings """ -from openedx.core.djangoapps.waffle_utils import (WaffleSwitch, WaffleSwitchNamespace) - -WAFFLE_SWITCH_NAMESPACE = WaffleSwitchNamespace(name='enrollment_api_rate_limit') - -USE_RATE_LIMIT_400_FOR_STAFF_FOR_ENROLLMENT_API = WaffleSwitch(WAFFLE_SWITCH_NAMESPACE, 'staff_rate_limit_400') -USE_RATE_LIMIT_100_FOR_STAFF_FOR_ENROLLMENT_API = WaffleSwitch(WAFFLE_SWITCH_NAMESPACE, 'staff_rate_limit_100') -USE_RATE_LIMIT_40_FOR_ENROLLMENT_API = WaffleSwitch(WAFFLE_SWITCH_NAMESPACE, 'rate_limit_40') diff --git a/common/djangoapps/enrollment/views.py b/common/djangoapps/enrollment/views.py index e5d25a22ddba696ad4cd29145537e9e42ae7d348..1b552b2ae9e5b4433f9b2fc3fff75469e79e7753 100644 --- a/common/djangoapps/enrollment/views.py +++ b/common/djangoapps/enrollment/views.py @@ -12,11 +12,6 @@ from django.utils.decorators import method_decorator from edx_rest_framework_extensions.authentication import JwtAuthentication from enrollment import api from enrollment.errors import CourseEnrollmentError, CourseEnrollmentExistsError, CourseModeNotFoundError -from enrollment import ( - USE_RATE_LIMIT_100_FOR_STAFF_FOR_ENROLLMENT_API, - USE_RATE_LIMIT_40_FOR_ENROLLMENT_API, - USE_RATE_LIMIT_400_FOR_STAFF_FOR_ENROLLMENT_API, -) from opaque_keys import InvalidKeyError from opaque_keys.edx.keys import CourseKey @@ -81,34 +76,14 @@ class ApiKeyPermissionMixIn(object): class EnrollmentUserThrottle(UserRateThrottle, ApiKeyPermissionMixIn): """Limit the number of requests users can make to the enrollment API.""" - # TODO: After confirming that reducing the throttle is successful, remove - # and clean up waffles. The rate limit has been increased over the course - # of a few months to account for unnecessary calls from the ecommerce - # service. These calls are no longer made and the plan is to set the - # rate limit back to its original state. LEARNER-5148 + # To see how the staff rate limit was selected, see https://github.com/edx/edx-platform/pull/18360 THROTTLE_RATES = { 'user': '40/minute', - 'staff': '2000/minute', + 'staff': '120/minute', } def allow_request(self, request, view): - if USE_RATE_LIMIT_400_FOR_STAFF_FOR_ENROLLMENT_API.is_enabled(): - self.THROTTLE_RATES = { - 'user': '40/minute', - 'staff': '400/minute', - } - elif USE_RATE_LIMIT_100_FOR_STAFF_FOR_ENROLLMENT_API.is_enabled(): - self.THROTTLE_RATES = { - 'user': '40/minute', - 'staff': '100/minute', - } - elif USE_RATE_LIMIT_40_FOR_ENROLLMENT_API.is_enabled(): - self.THROTTLE_RATES = { - 'user': '40/minute', - 'staff': '40/minute', - } - # Use a special scope for staff to allow for a separate throttle rate user = request.user if user.is_authenticated and (user.is_staff or user.is_superuser):