mirror of
https://github.com/ansible/awx.git
synced 2026-01-16 20:30:46 -03:30
trick django-polymorphic into allowing defer() on polymorphic objects
django-polymorphic itself generates queries for polymorphic object lookups, and these queries for UnifiedJob are *not* properly defering the `result_stdout_text` column, resulting in more very slow queries. This solution is _very_ hacky, and very specific to this specific version of Django and django-polymorphic, but it works until we can solve this problem the proper way in 3.3 (by removing large stdout blobs from the database). see: https://github.com/ansible/ansible-tower/issues/7568
This commit is contained in:
parent
436df168f0
commit
1bb6c17fe2
@ -145,3 +145,15 @@ activity_stream_registrar.connect(WorkflowJob)
|
||||
|
||||
# prevent API filtering on certain Django-supplied sensitive fields
|
||||
prevent_search(User._meta.get_field('password'))
|
||||
|
||||
# Always, always, always defer result_stdout_text for polymorphic UnifiedJob rows
|
||||
def defer_stdout(f):
|
||||
def _wrapped(*args, **kwargs):
|
||||
objs = f(*args, **kwargs)
|
||||
objs.query.deferred_loading[0].add('result_stdout_text')
|
||||
return objs
|
||||
return _wrapped
|
||||
|
||||
|
||||
for cls in UnifiedJob.__subclasses__():
|
||||
cls.base_objects.filter = defer_stdout(cls.base_objects.filter)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user