diff --git a/nau_openedx_extensions/student/admin.py b/nau_openedx_extensions/student/admin.py index 746035e..d8912e8 100644 --- a/nau_openedx_extensions/student/admin.py +++ b/nau_openedx_extensions/student/admin.py @@ -10,6 +10,7 @@ CourseAccessRole, CourseEnrollment, ) +from common.djangoapps.util.query import use_read_replica_if_available # lint-amnesty, pylint: disable=import-error from django.contrib import admin from nau_openedx_extensions.utils.admin import ExportCsvMixin @@ -59,7 +60,9 @@ def openedx_email(self, instance): # Changes from upstream: # - remove the custom order by / sort; # - remove the select_related user; +# - search only if search term has minimum 3 characters length; # - change search by user username or email; +# - use `read_replica` database if available for search; @admin.register(CourseEnrollment) class NAUCourseEnrollmentAdmin(DisableEnrollmentAdminMixin, admin.ModelAdmin): """ @@ -80,4 +83,4 @@ def get_search_results(self, request, queryset, search_term): qs, use_distinct = super().get_search_results(request, queryset, search_term) if not search_term or len(search_term) < 3: qs = CourseEnrollment.objects.none() - return qs, use_distinct + return use_read_replica_if_available(qs), use_distinct