From 44a8da83c2d6cfab805a05b6a0871fb419b1a3a2 Mon Sep 17 00:00:00 2001 From: Akita Noek Date: Fri, 22 Apr 2016 12:26:50 -0400 Subject: [PATCH 1/2] Removed all encompassing .distinct() call for all views This .distinct() call applied .distinct() to all list query sets. Most query sets are already unique, and adding .distinct causes the database to do a lot of extra work. Views that rely on this behavior will be rooted out during the hardening sprint and .distinct() will be added to the individual querysets as needed instead of applying this everywhere. --- awx/api/filters.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/awx/api/filters.py b/awx/api/filters.py index 367fd0eda5..abe92861c0 100644 --- a/awx/api/filters.py +++ b/awx/api/filters.py @@ -218,7 +218,7 @@ class FieldLookupBackend(BaseFilterBackend): q = Q(**{k:v}) queryset = queryset.filter(q) queryset = queryset.filter(*args) - return queryset.distinct() + return queryset except (FieldError, FieldDoesNotExist, ValueError), e: raise ParseError(e.args[0]) except ValidationError, e: From c18aa44cede94fe58adc101a7b68fea239294d8e Mon Sep 17 00:00:00 2001 From: Akita Noek Date: Fri, 22 Apr 2016 13:48:58 -0400 Subject: [PATCH 2/2] Return Queryset instead of Manager fix --- awx/api/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/awx/api/views.py b/awx/api/views.py index 1e72d18bee..3e70cb8099 100644 --- a/awx/api/views.py +++ b/awx/api/views.py @@ -3573,7 +3573,7 @@ class RoleChildrenList(SubListAPIView): # XXX: This should be the intersection between the roles of the user # and the roles that the requesting user has access to see role = Role.objects.get(pk=self.kwargs['pk']) - return role.children + return role.children.all()