mirror of
https://github.com/ansible/awx.git
synced 2026-05-08 01:47:35 -02: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:
@@ -145,3 +145,15 @@ activity_stream_registrar.connect(WorkflowJob)
|
|||||||
|
|
||||||
# prevent API filtering on certain Django-supplied sensitive fields
|
# prevent API filtering on certain Django-supplied sensitive fields
|
||||||
prevent_search(User._meta.get_field('password'))
|
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)
|
||||||
|
|||||||
Reference in New Issue
Block a user