mirror of
https://github.com/ansible/awx.git
synced 2026-05-07 17:37:37 -02:30
Merge pull request #9251 from Saurabh-Thakre/Saurabh-Thakre-patch-1
Fixed the Customized Notification returning incorrect values for host_status_counts Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
This commit is contained in:
@@ -388,12 +388,17 @@ class JobNotificationMixin(object):
|
|||||||
and a url to the job run."""
|
and a url to the job run."""
|
||||||
job_context = {'host_status_counts': {}}
|
job_context = {'host_status_counts': {}}
|
||||||
summary = None
|
summary = None
|
||||||
if hasattr(self, 'job_host_summaries'):
|
try:
|
||||||
summary = self.job_host_summaries.first()
|
has_event_property = any([f for f in self.event_class._meta.fields if f.name == 'event'])
|
||||||
if summary:
|
except NotImplementedError:
|
||||||
from awx.api.serializers import JobHostSummarySerializer
|
has_event_property = False
|
||||||
summary_data = JobHostSummarySerializer(summary).to_representation(summary)
|
if has_event_property:
|
||||||
job_context['host_status_counts'] = summary_data
|
qs = self.get_event_queryset()
|
||||||
|
if qs:
|
||||||
|
event = qs.only('event_data').filter(event='playbook_on_stats').first()
|
||||||
|
if event:
|
||||||
|
summary = event.get_host_status_counts()
|
||||||
|
job_context['host_status_counts'] = summary
|
||||||
context = {
|
context = {
|
||||||
'job': job_context,
|
'job': job_context,
|
||||||
'job_friendly_name': self.get_notification_friendly_name(),
|
'job_friendly_name': self.get_notification_friendly_name(),
|
||||||
|
|||||||
Reference in New Issue
Block a user