diff --git a/awx/api/views.py b/awx/api/views.py index e75a5288ed..5400f2491e 100644 --- a/awx/api/views.py +++ b/awx/api/views.py @@ -2966,7 +2966,11 @@ class JobJobTasksList(BaseJobEventsList): return ({'detail': 'Parent event not found.'}, -1, status.HTTP_404_NOT_FOUND) parent_task = parent_task[0] - queryset = JobEvent.start_event_queryset(parent_task) + # Some events correspond to a playbook or task starting up, + # and these are what we're interested in here. + STARTING_EVENTS = ('playbook_on_task_start', 'playbook_on_setup') + + queryset = JobEvent.start_event_queryset(parent_task, STARTING_EVENTS) # The data above will come back in a list, but we are going to # want to access it based on the parent id, so map it into a diff --git a/awx/main/models/jobs.py b/awx/main/models/jobs.py index 552a30a285..ff8cb6702d 100644 --- a/awx/main/models/jobs.py +++ b/awx/main/models/jobs.py @@ -11,7 +11,7 @@ from urlparse import urljoin # Django from django.conf import settings from django.db import models -from django.db.models import Q +from django.db.models import Q, Count from django.utils.translation import ugettext_lazy as _ from django.core.exceptions import ValidationError from django.core.urlresolvers import reverse @@ -1206,12 +1206,9 @@ class JobEvent(CreatedModifiedModel): job.inventory.update_computed_fields() emit_websocket_notification('/socket.io/jobs', 'summary_complete', dict(unified_job_id=job.id)) - @property - def STARTING_EVENTS(): - return ('playbook_on_task_start', 'playbook_on_setup') @classmethod - def get_startevent_queryset(cls, parent_task, ordering=None): + def start_event_queryset(cls, parent_task, starting_events, ordering=None): ''' We need to pull information about each start event. @@ -1221,7 +1218,7 @@ class JobEvent(CreatedModifiedModel): need stats on grandchildren, sorted by child. ''' qs = (JobEvent.objects.filter(parent__parent=parent_task, - parent__event__in=STARTING_EVENTS) + parent__event__in=starting_events) .values('parent__id', 'event', 'changed') .annotate(num=Count('event')) .order_by('parent__id'))