mirror of
https://github.com/ansible/awx.git
synced 2026-03-05 02:31:03 -03:30
Improve query time by removing a check from the order by filter handler
This commit is contained in:
@@ -277,12 +277,6 @@ class OrderByBackend(BaseFilterBackend):
|
|||||||
if field not in ('type', '-type'):
|
if field not in ('type', '-type'):
|
||||||
new_order_by.append(field)
|
new_order_by.append(field)
|
||||||
queryset = queryset.order_by(*new_order_by)
|
queryset = queryset.order_by(*new_order_by)
|
||||||
# Fetch the first result to run the query, otherwise we don't
|
|
||||||
# always catch the FieldError for invalid field names.
|
|
||||||
try:
|
|
||||||
queryset[0]
|
|
||||||
except IndexError:
|
|
||||||
pass
|
|
||||||
return queryset
|
return queryset
|
||||||
except FieldError, e:
|
except FieldError, e:
|
||||||
# Return a 400 for invalid field names.
|
# Return a 400 for invalid field names.
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import sys
|
|||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
|
from django.core.exceptions import FieldError
|
||||||
from django.db.models import Q, Count, Sum
|
from django.db.models import Q, Count, Sum
|
||||||
from django.db import IntegrityError, transaction
|
from django.db import IntegrityError, transaction
|
||||||
from django.shortcuts import get_object_or_404
|
from django.shortcuts import get_object_or_404
|
||||||
@@ -62,6 +63,8 @@ def api_exception_handler(exc):
|
|||||||
'''
|
'''
|
||||||
if isinstance(exc, IntegrityError):
|
if isinstance(exc, IntegrityError):
|
||||||
exc = ParseError(exc.args[0])
|
exc = ParseError(exc.args[0])
|
||||||
|
if isinstance(exc, FieldError):
|
||||||
|
exc = ParseError(exc.args[0])
|
||||||
return exception_handler(exc)
|
return exception_handler(exc)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user