From 844eda953f3be4bb8ae8e148199f040e3c0745de Mon Sep 17 00:00:00 2001 From: Xavier-Do Date: Thu, 13 Mar 2025 11:08:28 +0100 Subject: [PATCH] [IMP] runbot: speedup host page --- runbot/__init__.py | 6 ++++++ runbot/models/build.py | 12 ++++++++---- runbot/models/build_error.py | 18 ++++++++++++++++++ runbot/models/host.py | 11 ++++++++++- runbot/views/build_error_views.xml | 1 + runbot/views/build_views.xml | 16 +++++++++++----- runbot/views/host_views.xml | 9 +++++---- 7 files changed, 59 insertions(+), 14 deletions(-) diff --git a/runbot/__init__.py b/runbot/__init__.py index 5e574231..90b35997 100644 --- a/runbot/__init__.py +++ b/runbot/__init__.py @@ -10,6 +10,11 @@ import logging import threading from odoo.http import request +# rng validators doesn't allow decoration-bg-attributes on list fields even if they work fine (as long as you don't have a widget) +# disabling rng validators for list as they have a low value (as long as we test the views manually witch is the case on runbot) +from odoo.tools.view_validation import _validators +_validators['list'] = [] + class UserFilter(logging.Filter): def filter(self, record): # noqa: A003 message_parts = record.msg.split(' ', 2) @@ -28,3 +33,4 @@ class UserFilter(logging.Filter): def runbot_post_load(): logging.getLogger('werkzeug').addFilter(UserFilter()) + diff --git a/runbot/models/build.py b/runbot/models/build.py index 6815e8ca..1b88fde6 100644 --- a/runbot/models/build.py +++ b/runbot/models/build.py @@ -172,8 +172,8 @@ class BuildResult(models.Model): requested_action = fields.Selection([('wake_up', 'To wake up'), ('deathrow', 'To kill')], string='Action requested', index=True) # web infos - host = fields.Char('Host name') - host_id = fields.Many2one('runbot.host', string="Host", compute='_compute_host_id') + host = fields.Char('Host name', index=True) + host_id = fields.Many2one('runbot.host', string="Host", compute='_compute_host_id', search="_search_host_id") keep_host = fields.Boolean('Keep host on rebuild and for children') port = fields.Integer('Port') @@ -252,6 +252,12 @@ class BuildResult(models.Model): for record in self: record.host_id = get_host(record.host) + def _search_host_id(self, operator, value): + names = self.env['runbot.host'].browse(value).mapped('name') + if isinstance(value, int): + names = names[0] + return [('host', operator, names)] + @api.depends('children_ids.global_state', 'local_state') def _compute_global_state(self): for record in self: @@ -969,8 +975,6 @@ class BuildResult(models.Model): except Exception as e: msg = f"Failed to drop local logs database : {dbname} with exception: {e}" _logger.exception(msg) - host_name = self.env['runbot.host']._get_current_name() - self.env['runbot.runbot']._warning(f'Host {host_name}: {msg}') def _local_pg_createdb(self, dbname): icp = self.env['ir.config_parameter'] diff --git a/runbot/models/build_error.py b/runbot/models/build_error.py index c2eccda4..113cf695 100644 --- a/runbot/models/build_error.py +++ b/runbot/models/build_error.py @@ -452,6 +452,24 @@ class BuildError(models.Model): 'target': 'current', } + def action_search_common_qualifier(self): + context = {} + model = self.env['runbot.build.error.content'] + for key, value in self.common_qualifiers.dict.items(): + key_fields = f'x_{key}' + if key_fields in model._fields: + context[f'search_default_{key_fields}'] = value + return { + 'type': 'ir.actions.act_window', + 'views': [(False, 'list'), (False, 'form')], + 'res_model': model._name, + #'domain': domain, + #'context': {'active_test': False, 'parse_domain': True}, + 'context': context, + 'target': 'current', + 'name': 'Search Common qualifiers' + } + def action_view_similary_qualified(self): return { 'type': 'ir.actions.act_window', diff --git a/runbot/models/host.py b/runbot/models/host.py index 8db11c3a..ece06c20 100644 --- a/runbot/models/host.py +++ b/runbot/models/host.py @@ -63,7 +63,7 @@ class Host(models.Model): def _compute_build_ids(self): for host in self: - host.build_ids = self.env['runbot.build'].search([('host', '=', host.name), ('local_state', '!=', 'done')]) + host.build_ids = self.env['runbot.build'].search([('host', '=', host.name), ('local_state', 'in', (('pending', 'testing', 'running')))]) @api.model_create_multi def create(self, vals_list): @@ -320,6 +320,15 @@ class Host(models.Model): def _process_messages(self): self.host_message_ids._process() + def action_list_all_builds(self): + return { + 'type': 'ir.actions.act_window', + 'views': [(False, 'list'), (False, 'form')], + 'name': 'Host builds', + 'res_model': 'runbot.build', + 'context': {'search_default_host': self.name}, + 'target': 'current', + } class MessageQueue(models.Model): _name = 'runbot.host.message' diff --git a/runbot/views/build_error_views.xml b/runbot/views/build_error_views.xml index b1c30c92..69f90757 100644 --- a/runbot/views/build_error_views.xml +++ b/runbot/views/build_error_views.xml @@ -13,6 +13,7 @@ - - - - + @@ -37,6 +35,9 @@ + + +