From 7d50ce104afba5810523bb2de87378052e84a06e Mon Sep 17 00:00:00 2001 From: Jawayria <39649635+Jawayria@users.noreply.github.com> Date: Thu, 7 Oct 2021 17:52:45 +0500 Subject: [PATCH] refactor: use value to filter indexed boolean field (#28970) * refactor: use value to filter indexed boolean field * Update views.py Co-authored-by: Awais Qureshi --- openedx/core/djangoapps/user_api/accounts/views.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/openedx/core/djangoapps/user_api/accounts/views.py b/openedx/core/djangoapps/user_api/accounts/views.py index b67e218ff1..f5568dd76e 100644 --- a/openedx/core/djangoapps/user_api/accounts/views.py +++ b/openedx/core/djangoapps/user_api/accounts/views.py @@ -20,7 +20,7 @@ from django.conf import settings from django.contrib.auth import authenticate, get_user_model, logout from django.contrib.sites.models import Site from django.core.cache import cache -from django.db import transaction +from django.db import models, transaction from django.utils.translation import ugettext as _ from edx_ace import ace from edx_ace.recipient import Recipient @@ -649,7 +649,9 @@ class AccountRetirementPartnerReportView(ViewSet): try: # if the user has ever launched a managed Zoom xblock, # we'll notify Zoom to delete their records. - if user.launchlog_set.filter(managed=True).count(): + # We use models.Value(1) to make use of the indexing on the field. MySQL does not + # support boolean types natively, and checking for False will cause a table scan. + if user.launchlog_set.filter(managed=models.Value(1)).count(): orgs.add('zoom') except AttributeError: # Zoom XBlock not installed