1
0
mirror of https://github.com/ansible/awx.git synced 2024-10-31 23:51:09 +03:00

Fix a minor typo in job events model and restructure a bit to fix 500 error.

This commit is contained in:
Aaron Tan 2016-08-08 13:41:59 -04:00
parent f30292c7f1
commit a2093e3e13
2 changed files with 8 additions and 7 deletions

View File

@ -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

View File

@ -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'))