mirror of
https://github.com/ansible/awx.git
synced 2024-11-01 08:21:15 +03:00
Merge pull request #4381 from AlanCoding/prefetch_optimizing
Use prefetch_related for several more things
This commit is contained in:
commit
39e5765f12
@ -1024,6 +1024,7 @@ class ProjectList(ListCreateAPIView):
|
||||
'update_role',
|
||||
'read_role',
|
||||
)
|
||||
projects_qs = projects_qs.prefetch_related('last_job', 'created_by')
|
||||
return projects_qs
|
||||
|
||||
|
||||
@ -1579,6 +1580,7 @@ class InventoryList(ListCreateAPIView):
|
||||
def get_queryset(self):
|
||||
qs = Inventory.accessible_objects(self.request.user, 'read_role')
|
||||
qs = qs.select_related('admin_role', 'read_role', 'update_role', 'use_role', 'adhoc_role')
|
||||
qs = qs.prefetch_related('created_by', 'modified_by', 'organization')
|
||||
return qs
|
||||
|
||||
|
||||
|
@ -1809,6 +1809,9 @@ class UnifiedJobTemplateAccess(BaseAccess):
|
||||
'created_by',
|
||||
'modified_by',
|
||||
'next_schedule',
|
||||
)
|
||||
# prefetch last/current jobs so we get the real instance
|
||||
qs = qs.prefetch_related(
|
||||
'last_job',
|
||||
'current_job',
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user