[Patchew-devel] [PATCH 11/12] do not load log when accessing api_result

Paolo Bonzini pbonzini at redhat.com
Tue May 22 06:57:39 UTC 2018


This is a small optimization.  log_xz can be largish, and we do not
need it except in the log viewer or when retrieving it for the REST API.
Skipping it by default in all result queries is the simplest thing to
do.

Signed-off-by: Paolo Bonzini <pbonzini at redhat.com>
---
 mods/git.py     | 2 +-
 mods/testing.py | 4 ++--
 www/views.py    | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/mods/git.py b/mods/git.py
index 67ef723..58b9c3d 100644
--- a/mods/git.py
+++ b/mods/git.py
@@ -28,7 +28,7 @@ _instance = None
 
 def _get_git_result(msg):
     try:
-        return msg.results.get(name="git")
+        return msg.results.defer('log_xz').get(name="git")
     except:
         return None
 Message.git_result = property(_get_git_result)
diff --git a/mods/testing.py b/mods/testing.py
index b09989b..640389f 100644
--- a/mods/testing.py
+++ b/mods/testing.py
@@ -122,11 +122,11 @@ class TestingModule(PatchewModule):
             self.recalc_pending_tests(obj)
 
     def get_testing_results(self, obj, *args, **kwargs):
-        return obj.results.filter(name__startswith='testing.', *args, **kwargs)
+        return obj.results.defer('log_xz').filter(name__startswith='testing.', *args, **kwargs)
 
     def get_testing_result(self, obj, name):
         try:
-            return obj.results.get(name='testing.' + name)
+            return obj.results.defer('log_xz').get(name='testing.' + name)
         except:
             raise Http404("Test doesn't exist")
 
diff --git a/www/views.py b/www/views.py
index 5685f23..ddae4ca 100644
--- a/www/views.py
+++ b/www/views.py
@@ -93,7 +93,7 @@ def prepare_series(request, s, skip_patches=False):
 
 def prepare_results(request, obj):
     rendered_results = []
-    for result in obj.results.all():
+    for result in obj.results.defer('log_xz').all():
         html = result.render(obj)
         if html is None:
             continue
-- 
2.17.0





More information about the Patchew-devel mailing list