mirror of
https://github.com/ansible/awx.git
synced 2026-05-08 18:07:36 -02:30
Revert "remove partial dependency job id logic"
This reverts commit 4bb3a4909e616209fc291b2b3cee46469bc58f9e.
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
|
|
||||||
# Python
|
# Python
|
||||||
import json
|
import json
|
||||||
|
import itertools
|
||||||
|
|
||||||
# AWX
|
# AWX
|
||||||
from awx.main.utils import decrypt_field_value
|
from awx.main.utils import decrypt_field_value
|
||||||
@@ -61,13 +62,35 @@ class PartialModelDict(object):
|
|||||||
def task_impact(self):
|
def task_impact(self):
|
||||||
raise RuntimeError("Inherit and implement me")
|
raise RuntimeError("Inherit and implement me")
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def merge_values(cls, values):
|
||||||
|
grouped_results = itertools.groupby(values, key=lambda value: value['id'])
|
||||||
|
|
||||||
|
merged_values = []
|
||||||
|
for k, g in grouped_results:
|
||||||
|
groups = list(g)
|
||||||
|
merged_value = {}
|
||||||
|
for group in groups:
|
||||||
|
for key, val in group.iteritems():
|
||||||
|
if not merged_value.get(key):
|
||||||
|
merged_value[key] = val
|
||||||
|
elif val != merged_value[key]:
|
||||||
|
if isinstance(merged_value[key], list):
|
||||||
|
if val not in merged_value[key]:
|
||||||
|
merged_value[key].append(val)
|
||||||
|
else:
|
||||||
|
old_val = merged_value[key]
|
||||||
|
merged_value[key] = [old_val, val]
|
||||||
|
merged_values.append(merged_value)
|
||||||
|
return merged_values
|
||||||
|
|
||||||
|
|
||||||
class JobDict(PartialModelDict):
|
class JobDict(PartialModelDict):
|
||||||
FIELDS = (
|
FIELDS = (
|
||||||
'id', 'status', 'job_template_id', 'inventory_id', 'project_id',
|
'id', 'status', 'job_template_id', 'inventory_id', 'project_id',
|
||||||
'launch_type', 'limit', 'allow_simultaneous', 'created',
|
'launch_type', 'limit', 'allow_simultaneous', 'created',
|
||||||
'job_type', 'celery_task_id', 'project__scm_update_on_launch',
|
'job_type', 'celery_task_id', 'project__scm_update_on_launch',
|
||||||
'forks', 'start_args',
|
'forks', 'start_args', 'dependent_jobs__id',
|
||||||
)
|
)
|
||||||
model = Job
|
model = Job
|
||||||
|
|
||||||
@@ -90,7 +113,8 @@ class JobDict(PartialModelDict):
|
|||||||
kv = {
|
kv = {
|
||||||
'status__in': status
|
'status__in': status
|
||||||
}
|
}
|
||||||
return [cls(o) for o in cls.model.objects.filter(**kv).values(*cls.get_db_values())]
|
merged = PartialModelDict.merge_values(cls.model.objects.filter(**kv).values(*cls.get_db_values()))
|
||||||
|
return [cls(o) for o in merged]
|
||||||
|
|
||||||
|
|
||||||
class ProjectUpdateDict(PartialModelDict):
|
class ProjectUpdateDict(PartialModelDict):
|
||||||
|
|||||||
Reference in New Issue
Block a user