mirror of
https://github.com/ansible/awx.git
synced 2026-01-10 15:32:07 -03:30
Merge pull request #8007 from ryanpetrello/defer-artifacts
defer loading Job.artifacts and .extra_vars on host views to improve performance Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
This commit is contained in:
commit
2fa8b7e594
@ -1702,7 +1702,10 @@ class HostSerializer(BaseSerializerWithVariables):
|
||||
'type': j.job.job_type_name,
|
||||
'status': j.job.status,
|
||||
'finished': j.job.finished,
|
||||
} for j in obj.job_host_summaries.select_related('job__job_template').order_by('-created')[:5]])
|
||||
} for j in obj.job_host_summaries.select_related('job__job_template').order_by('-created').defer(
|
||||
'job__extra_vars',
|
||||
'job__artifacts',
|
||||
)[:5]])
|
||||
return d
|
||||
|
||||
def _get_host_port_from_name(self, name):
|
||||
|
||||
@ -48,7 +48,13 @@ class HostManager(models.Manager):
|
||||
"""When the parent instance of the host query set has a `kind=smart` and a `host_filter`
|
||||
set. Use the `host_filter` to generate the queryset for the hosts.
|
||||
"""
|
||||
qs = super(HostManager, self).get_queryset()
|
||||
qs = super(HostManager, self).get_queryset().defer(
|
||||
'last_job__extra_vars',
|
||||
'last_job_host_summary__job__extra_vars',
|
||||
'last_job__artifacts',
|
||||
'last_job_host_summary__job__artifacts',
|
||||
)
|
||||
|
||||
if (hasattr(self, 'instance') and
|
||||
hasattr(self.instance, 'host_filter') and
|
||||
hasattr(self.instance, 'kind')):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user