[Qa-jenkins-scm] [jenkins.debian.net] 01/01: reproducible debian: Package: make the history a @property to load it only when actually requested

Mattia Rizzolo mattia at debian.org
Fri Apr 6 23:42:50 UTC 2018


This is an automated email from the git hooks/post-receive script.

mattia pushed a commit to branch master
in repository jenkins.debian.net.

commit 66483277702c8d60219dc58e053c431025e4d9eb
Author: Mattia Rizzolo <mattia at debian.org>
Date:   Sat Apr 7 01:38:00 2018 +0200

    reproducible debian: Package: make the history a @property to load it only when actually requested
    
    this class is used on many instances where loading the whole history is
    not needed.
    I expect this to sensibly lower the runtime of of jobs like _html_notes
    and _html_all_packages
    
    Signed-off-by: Mattia Rizzolo <mattia at debian.org>
---
 bin/reproducible_common.py | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/bin/reproducible_common.py b/bin/reproducible_common.py
index e5b7ce0..929a524 100755
--- a/bin/reproducible_common.py
+++ b/bin/reproducible_common.py
@@ -826,10 +826,16 @@ class Package:
         except IndexError:
             result = 0
         self.notify_maint = '⚑' if result == 1 else ''
-        self.history = []
-        self._load_history()
+        self._history = None
+
+    @property
+    def history(self):
+        if self._history is None:
+            self._load_history()
+        return self._history
 
     def _load_history(self):
+        self._history = []
         keys = ['build ID', 'version', 'suite', 'architecture', 'result',
             'build date', 'build duration', 'node1', 'node2', 'job',
             'schedule message']
@@ -840,7 +846,7 @@ class Package:
             """.format(self.name)
         results = query_db(query)
         for record in results:
-            self.history.append(dict(zip(keys, record)))
+            self._history.append(dict(zip(keys, record)))
 
     def get_status(self, suite, arch):
         """ This returns False if the package does not exists in this suite """

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/qa/jenkins.debian.net.git



More information about the Qa-jenkins-scm mailing list