From 84d9425bdcb6311711a7ea7a99552c4750121f46 Mon Sep 17 00:00:00 2001 From: Xavier-Do Date: Fri, 9 Apr 2021 14:44:26 +0200 Subject: [PATCH] [FIX] runbot: various view fixes - fix missing batch references on builds - fix group on action buttons --- runbot/models/build.py | 10 ++++------ runbot/models/build_error.py | 2 +- runbot/models/runbot.py | 3 +-- runbot/models/upgrade.py | 2 +- runbot/templates/build.xml | 30 ++++++++++++------------------ runbot/templates/build_error.xml | 4 ++-- runbot/templates/bundle.xml | 4 ++-- runbot/templates/commit.xml | 2 +- runbot/templates/utils.xml | 2 +- 9 files changed, 25 insertions(+), 34 deletions(-) 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 @@ -
- - - Force Rebuild - -
- + @@ -55,6 +49,17 @@
+
+ Parent build: + + + + + &nbsp; + + &nbsp;Orphaned build, the result does not affect parent build result + +
@@ -196,17 +201,6 @@
-

- Child of - - - - - &nbsp; - - &nbsp;Orphaned build, the result does not affect parent build result - -

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 @@
- + @@ -116,7 +116,7 @@
- + diff --git a/runbot/templates/bundle.xml b/runbot/templates/bundle.xml index d366aed7..f6c52925 100644 --- a/runbot/templates/bundle.xml +++ b/runbot/templates/bundle.xml @@ -14,10 +14,10 @@ - + - + diff --git a/runbot/templates/commit.xml b/runbot/templates/commit.xml index 7435f0c9..82820f73 100644 --- a/runbot/templates/commit.xml +++ b/runbot/templates/commit.xml @@ -81,7 +81,7 @@ -
Date + 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 @@ +