mirror of
https://github.com/ansible/awx.git
synced 2026-03-04 02:01:01 -03:30
prefetch UnifiedJob related credentials
This commit is contained in:
@@ -1939,6 +1939,7 @@ class UnifiedJobTemplateAccess(BaseAccess):
|
|||||||
prefetch_related = (
|
prefetch_related = (
|
||||||
'last_job',
|
'last_job',
|
||||||
'current_job',
|
'current_job',
|
||||||
|
'credentials__credential_type',
|
||||||
Prefetch('labels', queryset=Label.objects.all().order_by('name')),
|
Prefetch('labels', queryset=Label.objects.all().order_by('name')),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -1982,6 +1983,7 @@ class UnifiedJobAccess(BaseAccess):
|
|||||||
'unified_job_node__workflow_job',
|
'unified_job_node__workflow_job',
|
||||||
'unified_job_template',
|
'unified_job_template',
|
||||||
'instance_group',
|
'instance_group',
|
||||||
|
'credentials__credential_type',
|
||||||
Prefetch('labels', queryset=Label.objects.all().order_by('name')),
|
Prefetch('labels', queryset=Label.objects.all().order_by('name')),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -185,9 +185,10 @@ class JobOptions(BaseModel):
|
|||||||
return cred.pk
|
return cred.pk
|
||||||
|
|
||||||
def get_deprecated_credential(self, kind):
|
def get_deprecated_credential(self, kind):
|
||||||
try:
|
for cred in self.credentials.all():
|
||||||
return self.credentials.filter(credential_type__kind=kind).first()
|
if cred.credential_type.kind == kind:
|
||||||
except IndexError:
|
return cred
|
||||||
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# TODO: remove when API v1 is removed
|
# TODO: remove when API v1 is removed
|
||||||
|
|||||||
Reference in New Issue
Block a user