Merge pull request #8193 from ryanpetrello/ws-broadcast-limited

add a few additional optimizations to the callback receiver

Reviewed-by: Shane McDonald <me@shanemcd.com>
             https://github.com/shanemcd
This commit is contained in:
softwarefactory-project-zuul[bot]
2020-09-23 14:58:41 +00:00
committed by GitHub
4 changed files with 37 additions and 5 deletions

View File

@@ -4,6 +4,7 @@ import datetime
import logging
from collections import defaultdict
from django.conf import settings
from django.db import models, DatabaseError, connection
from django.utils.dateparse import parse_datetime
from django.utils.text import Truncator
@@ -57,7 +58,18 @@ def create_host_status_counts(event_data):
return dict(host_status_counts)
MINIMAL_EVENTS = set([
'playbook_on_play_start', 'playbook_on_task_start',
'playbook_on_stats', 'EOF'
])
def emit_event_detail(event):
if (
settings.UI_LIVE_UPDATES_ENABLED is False and
event.event not in MINIMAL_EVENTS
):
return
cls = event.__class__
relation = {
JobEvent: 'job_id',
@@ -368,10 +380,11 @@ class BasePlaybookEvent(CreatedModifiedModel):
value = force_text(event_data.get(field, '')).strip()
if value != getattr(self, field):
setattr(self, field, value)
analytics_logger.info(
'Event data saved.',
extra=dict(python_objects=dict(job_event=self))
)
if settings.LOG_AGGREGATOR_ENABLED:
analytics_logger.info(
'Event data saved.',
extra=dict(python_objects=dict(job_event=self))
)
@classmethod
def create_from_data(cls, **kwargs):