Skip to content

Commit bd79c81

Browse files
committed
[IMP] runbot: speedup host page
1 parent 9097aa4 commit bd79c81

File tree

7 files changed

+58
-14
lines changed

7 files changed

+58
-14
lines changed

runbot/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,8 @@ def filter(self, record): # noqa: A003
2828

2929
def runbot_post_load():
3030
logging.getLogger('werkzeug').addFilter(UserFilter())
31+
32+
33+
from odoo.tools.view_validation import _validators
34+
35+
_validators['list'] = [] # mainly to be able to add bg in views

runbot/models/build.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,8 @@ class BuildResult(models.Model):
172172

173173
requested_action = fields.Selection([('wake_up', 'To wake up'), ('deathrow', 'To kill')], string='Action requested', index=True)
174174
# web infos
175-
host = fields.Char('Host name')
176-
host_id = fields.Many2one('runbot.host', string="Host", compute='_compute_host_id')
175+
host = fields.Char('Host name', index=True)
176+
host_id = fields.Many2one('runbot.host', string="Host", compute='_compute_host_id', search="_search_host_id")
177177
keep_host = fields.Boolean('Keep host on rebuild and for children')
178178

179179
port = fields.Integer('Port')
@@ -252,6 +252,12 @@ def _compute_host_id(self):
252252
for record in self:
253253
record.host_id = get_host(record.host)
254254

255+
def _search_host_id(self, operator, value):
256+
names = self.env['runbot.host'].browse(value).mapped('name')
257+
if isinstance(value, int):
258+
names = names[0]
259+
return [('host', operator, names)]
260+
255261
@api.depends('children_ids.global_state', 'local_state')
256262
def _compute_global_state(self):
257263
for record in self:
@@ -969,8 +975,6 @@ def _local_pg_dropdb(self, dbname):
969975
except Exception as e:
970976
msg = f"Failed to drop local logs database : {dbname} with exception: {e}"
971977
_logger.exception(msg)
972-
host_name = self.env['runbot.host']._get_current_name()
973-
self.env['runbot.runbot']._warning(f'Host {host_name}: {msg}')
974978

975979
def _local_pg_createdb(self, dbname):
976980
icp = self.env['ir.config_parameter']

runbot/models/build_error.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,24 @@ def action_view_errors(self):
452452
'target': 'current',
453453
}
454454

455+
def action_search_common_qualifier(self):
456+
context = {}
457+
model = self.env['runbot.build.error.content']
458+
for key, value in self.common_qualifiers.dict.items():
459+
key_fields = f'x_{key}'
460+
if key_fields in model._fields:
461+
context[f'search_default_{key_fields}'] = value
462+
return {
463+
'type': 'ir.actions.act_window',
464+
'views': [(False, 'list'), (False, 'form')],
465+
'res_model': model._name,
466+
#'domain': domain,
467+
#'context': {'active_test': False, 'parse_domain': True},
468+
'context': context,
469+
'target': 'current',
470+
'name': 'Search Common qualifiers'
471+
}
472+
455473
def action_view_similary_qualified(self):
456474
return {
457475
'type': 'ir.actions.act_window',

runbot/models/host.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def _compute_nb(self):
6363

6464
def _compute_build_ids(self):
6565
for host in self:
66-
host.build_ids = self.env['runbot.build'].search([('host', '=', host.name), ('local_state', '!=', 'done')])
66+
host.build_ids = self.env['runbot.build'].search([('host', '=', host.name), ('local_state', 'in', (('pending', 'testing', 'running')))])
6767

6868
@api.model_create_multi
6969
def create(self, vals_list):
@@ -320,6 +320,15 @@ def _get_builds(self, domain, order=None):
320320
def _process_messages(self):
321321
self.host_message_ids._process()
322322

323+
def action_list_all_builds(self):
324+
return {
325+
'type': 'ir.actions.act_window',
326+
'views': [(False, 'list'), (False, 'form')],
327+
'name': 'Host builds',
328+
'res_model': 'runbot.build',
329+
'context': {'search_default_host': self.name},
330+
'target': 'current',
331+
}
323332

324333
class MessageQueue(models.Model):
325334
_name = 'runbot.host.message'

runbot/views/build_error_views.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
</div>
1414
<widget name="web_ribbon" title="Test-tags" bg_color="bg-danger" invisible="not test_tags"/>
1515
<button name="action_view_errors" string="See all linked errors" type="object" class="oe_highlight"/>
16+
<button name="action_search_common_qualifier" string="Search common_qualifiers" type="object" class="oe_highlight"/>
1617
<group string="Base info">
1718
<field name="name"/>
1819
<field name="error_content_ids" readonly="1">

runbot/views/build_views.xml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,12 @@
9393
<field name="arch" type="xml">
9494
<list string="Builds">
9595
<field name="dest"/>
96-
<field name="global_state"/>
96+
<field name="global_state"
97+
decoration-bg-danger="global_result == 'ko'"
98+
decoration-bg-warning="global_result == 'warn'"
99+
decoration-bg-success="global_result == 'ok' and global_state == 'done'"
100+
decoration-bg-info="global_result == 'ok' and global_state != 'done'"
101+
/>
97102
<field name="global_result"/>
98103
<field name="job"/>
99104
<field name="host"/>
@@ -119,16 +124,17 @@
119124
<field name="id"/>
120125
<field name="global_state"/>
121126
<field name="dest"/>
127+
<field name="host" operator="="/>
122128
<filter string="Pending" name='pending' domain="[('global_state','=', 'pending')]"/>
123129
<filter string="Testing" name='testing' domain="[('global_state','in', ('testing', 'waiting'))]"/>
124130
<filter string="Running" name='running' domain="[('global_state','=', 'running')]"/>
125131
<filter string="Done" name='done' domain="[('global_state','=','done')]"/>
126132
<filter string="Duplicate" name='duplicate' domain="[('local_state','=', 'duplicate')]"/>
127133
<group expand="0" string="Group By...">
128-
<filter string="Status" name='status' domain="[]" context="{'group_by':'global_state'}"/>
129-
<filter string="Result" name='result' domain="[]" context="{'group_by':'global_result'}"/>
130-
<filter string="Start" name='start' domain="[]" context="{'group_by':'job_start'}"/>
131-
<filter string="Host" name='host' domain="[]" context="{'group_by':'host'}"/>
134+
<filter string="Status" name='group_status' domain="[]" context="{'group_by':'global_state'}"/>
135+
<filter string="Result" name='group_result' domain="[]" context="{'group_by':'global_result'}"/>
136+
<filter string="Start" name='group_start' domain="[]" context="{'group_by':'job_start'}"/>
137+
<filter string="Host" name='group_host' domain="[]" context="{'group_by':'host'}"/>
132138
<filter string="Create Date" name='create_date' domain="[]" context="{'group_by':'create_date'}"/>
133139
</group>
134140
</search>

runbot/views/host_views.xml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,10 @@
2121
<field name="nb_run_slot"/>
2222
<field name="last_exception" readonly='1'/>
2323
<field name="exception_count" readonly='1'/>
24+
<button type="object" name="action_list_all_builds">See all host builds</button>
2425
</group>
2526
<notebook>
26-
<page string="Messages">
27-
<field name="host_message_ids" readonly='1'/>
28-
</page>
29-
<page string="Builds">
27+
<page string="Current Builds">
3028
<field name="build_ids" widget="many2many" options="{'not_delete': True, 'no_create_edit': True}" readonly='1'>
3129
<list string="Builds">
3230
<field name="create_date"/>
@@ -37,6 +35,9 @@
3735
</list>
3836
</field>
3937
</page>
38+
<page string="Messages">
39+
<field name="host_message_ids" readonly='1'/>
40+
</page>
4041
</notebook>
4142
</sheet>
4243
<chatter/>

0 commit comments

Comments
 (0)