diff --git a/runbot/models/build.py b/runbot/models/build.py index 0885016f..853efa41 100644 --- a/runbot/models/build.py +++ b/runbot/models/build.py @@ -199,6 +199,7 @@ class BuildResult(models.Model): parent_id = fields.Many2one('runbot.build', 'Parent Build', index=True) parent_path = fields.Char('Parent path', index=True) + top_parent = fields.Many2one('runbot.build', compute='_compute_top_parent') # should we add a has children stored boolean? children_ids = fields.One2many('runbot.build', 'parent_id') @@ -252,12 +253,9 @@ class BuildResult(models.Model): for build in self: build.md_description = pseudo_markdown(build.description) - def _get_top_parent(self): - self.ensure_one() - build = self - while build.parent_id: - build = build.parent_id - return build + def _compute_top_parent(self): + for build in self: + build.top_parent = self.browse(int(build.parent_path.split('/')[0])) def _get_youngest_state(self, states): index = min([self._get_state_score(state) for state in states]) diff --git a/runbot/models/build_error.py b/runbot/models/build_error.py index 0a005d74..f3e5bc4d 100644 --- a/runbot/models/build_error.py +++ b/runbot/models/build_error.py @@ -73,7 +73,7 @@ class BuildError(models.Model): @api.depends('build_ids') def _compute_bundle_ids(self): for build_error in self: - top_parent_builds = build_error.build_ids.mapped(lambda rec: rec and rec._get_top_parent()) + top_parent_builds = build_error.build_ids.mapped(lambda rec: rec and rec.top_parent) build_error.bundle_ids = top_parent_builds.mapped('slot_ids').mapped('batch_id.bundle_id') @api.depends('build_ids') diff --git a/runbot/models/runbot.py b/runbot/models/runbot.py index 5f5ef876..8dfc9d43 100644 --- a/runbot/models/runbot.py +++ b/runbot/models/runbot.py @@ -110,9 +110,8 @@ class Runbot(models.AbstractModel): return for build in testing_builds: - top_parent = build._get_top_parent() if build.killable: - top_parent._ask_kill(message='Build automatically killed, new build found.') + build.top_parent._ask_kill(message='Build automatically killed, new build found.') def _allocate_builds(self, host, nb_slots, domain=None): if nb_slots <= 0: diff --git a/runbot/models/upgrade.py b/runbot/models/upgrade.py index 705771e5..80d24f89 100644 --- a/runbot/models/upgrade.py +++ b/runbot/models/upgrade.py @@ -44,7 +44,7 @@ class BuildResult(models.Model): if exception: bundle = False - batches = self._get_top_parent().slot_ids.mapped('batch_id') + batches = self.top_parent.slot_ids.mapped('batch_id') if batches: bundle = batches[0].bundle_id.id res = { diff --git a/runbot/templates/build.xml b/runbot/templates/build.xml index 0ba3ee32..0bba87ed 100644 --- a/runbot/templates/build.xml +++ b/runbot/templates/build.xml @@ -13,16 +13,10 @@ -
- Child of
-
-
Date | diff --git a/runbot/templates/build_error.xml b/runbot/templates/build_error.xml index 26709f61..a0700fc9 100644 --- a/runbot/templates/build_error.xml +++ b/runbot/templates/build_error.xml @@ -42,7 +42,7 @@+ |
diff --git a/runbot/templates/utils.xml b/runbot/templates/utils.xml
index ce513c8d..83dd5726 100644
--- a/runbot/templates/utils.xml
+++ b/runbot/templates/utils.xml
@@ -166,7 +166,7 @@
|
---|