Skip to content

Commit

Permalink
Use read replica db for course enrollment admin
Browse files Browse the repository at this point in the history
Use `read_replica` Open edX database to search course enrollments.
GN-1145
  • Loading branch information
igobranco committed May 4, 2023
1 parent e32ee7c commit 19cf32d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion nau_openedx_extensions/student/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
"""
Expand All @@ -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

0 comments on commit 19cf32d

Please sign in to comment.