From 8314dd080a6ef530f4a197564b095c7f9bc0f1cf Mon Sep 17 00:00:00 2001 From: Xavier-Do Date: Tue, 2 Aug 2022 08:50:55 +0200 Subject: [PATCH] wip --- runbot/models/build.py | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/runbot/models/build.py b/runbot/models/build.py index a8b2ba7f..8ffba197 100644 --- a/runbot/models/build.py +++ b/runbot/models/build.py @@ -238,20 +238,6 @@ class BuildResult(models.Model): build.log_list = ','.join({step.name for step in build.params_id.config_id.step_ids() if step._has_log()}) # TODO replace logic, add log file to list when executed (avoid 404, link log on docker start, avoid fake is_docker_step) - @api.depends('children_ids.global_state', 'local_state') - def _compute_global_state(self): - for record in self: - waiting_score = record._get_state_score('waiting') - children_ids = [child for child in record.children_ids if not child.orphan_result] - if record._get_state_score(record.local_state) > waiting_score and children_ids: # if finish, check children - children_state = record._get_youngest_state([child.global_state for child in children_ids]) - if record._get_state_score(children_state) > waiting_score: - record.global_state = record.local_state - else: - record.global_state = 'waiting' - else: - record.global_state = record.local_state - @api.depends('gc_delay', 'job_end') def _compute_gc_date(self): icp = self.env['ir.config_parameter'].sudo() @@ -283,8 +269,7 @@ class BuildResult(models.Model): def _get_state_score(self, result): return state_order.index(result) - @api.depends('children_ids.global_result', 'local_result', 'children_ids.orphan_result') - def _compute_global_result(self): + def _update_globals(self): for record in self: if record.local_result and record._get_result_score(record.local_result) >= record._get_result_score('ko'): record.global_result = record.local_result @@ -299,6 +284,18 @@ class BuildResult(models.Model): else: record.global_result = record.local_result + for record in self: + waiting_score = record._get_state_score('waiting') + children_ids = [child for child in record.children_ids if not child.orphan_result] + if record._get_state_score(record.local_state) > waiting_score and children_ids: # if finish, check children + children_state = record._get_youngest_state([child.global_state for child in children_ids]) + if record._get_state_score(children_state) > waiting_score: + record.global_state = record.local_state + else: + record.global_state = 'waiting' + else: + record.global_state = record.local_state + def _get_worst_result(self, results, max_res=False): results = [result for result in results if result] # filter Falsy values index = max([self._get_result_score(result) for result in results]) if results else 0