diff --git a/awx/main/models/notifications.py b/awx/main/models/notifications.py index f30c4d2778..53860563e0 100644 --- a/awx/main/models/notifications.py +++ b/awx/main/models/notifications.py @@ -388,12 +388,17 @@ class JobNotificationMixin(object): and a url to the job run.""" job_context = {'host_status_counts': {}} summary = None - if hasattr(self, 'job_host_summaries'): - summary = self.job_host_summaries.first() - if summary: - from awx.api.serializers import JobHostSummarySerializer - summary_data = JobHostSummarySerializer(summary).to_representation(summary) - job_context['host_status_counts'] = summary_data + try: + has_event_property = any([f for f in self.event_class._meta.fields if f.name == 'event']) + except NotImplementedError: + has_event_property = False + if has_event_property: + 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 = { 'job': job_context, 'job_friendly_name': self.get_notification_friendly_name(),